Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unable to read vbLf and vbTab in POST request

    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

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,084
    Thanks
    80
    Thanked 4,552 Times in 4,516 Posts
    Try this:
    Code:
    str = "accountRequest=" _
        & Server.URLEncode("<NewUser>" & vbCrLf & "Hello" & vbTab & "World" & vbCrLf & "</NewUser>" )
    ASP code is, after all, running on a Windows platform, so you really should use CrLf as a line separator, not Lf alone.

    And you NEED Server.URLEncode() to ensure that many characters aren't misinterpreted. Dunno whether that applies to vbTab, but it's worth a shot.
    Last edited by Old Pedant; 03-01-2012 at 01:53 AM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •