Unable to read vbLf and vbTab in POST request
Hello All :wave: I'm afraid I'm in desperate need of help. I'm trying to understand why tabs and line feeds aren't coming through a POST request. Here's the code to reproduce:
POST request:
Code:
str = "accountRequest=<NewUser>" & vbLf & _
"Hello" & vbTab & "World" & vbLf & _
"</NewUser>"
Set objHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
objHTTP.open "POST", "service.asp", False
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.send str
response.Write(objHTTP.responseText)
Set objHTTP = Nothing
service.asp:
Code:
function w (str)
response.Write(str & "<br>")
end function
str = request.Form("accountRequest")
w(str)
w("Tabs: "& InStr(str,vbTab))
w("Lines: "& InStr(str,vbLf))
output:
Code:
HelloWorld
Tabs: 0
Lines: 0
Re: Unable to read vbLf and vbTab in POST request
Untested, but try specifying the charset as well:
Code:
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
Re: Unable to read vbLf and vbTab in POST request
It didn't work. I also tried specifying the charset in the response as well without luck.
Re: Unable to read vbLf and vbTab in POST request
ummm.... because it wasn't htmlencoded/urlencoded properly?
just a guess.
-tg
Re: Unable to read vbLf and vbTab in POST request
tg, you're right. In fact, it wasn't url encoded at all. I finally figured out that it doesn't matter if you do a $_POST in php which preserves the tab (\t). ASP's request method doesn't do it.