简体   繁体   中英

How to place carriage Return in HTTP Header value

I have an HTTP web request that looks something like the following:

    Dim myrequest As HttpWebRequest = HttpWebRequest.Create("myURL")
    myrequest.Proxy = Nothing
    myrequest.UserAgent = "AGENT"
    myrequest.Method = "POST"
    myrequest.ContentLength = 0

    myrequest.Headers.Add("KEY1", value)
    myrequest.Headers.Add("KEY2", value)


    Dim myresponse As HttpWebResponse = myrequest.GetResponse
    Dim mystream As System.IO.Stream = (myresponse.GetResponseStream)

    Dim streamreader As New System.IO.StreamReader(mystream)
    return streamreader.ReadToEnd

The problem is that I cannot send any of the following values to place a line break in a header value. So far, I have tried :

vbNewLine

vbCrLf

vbCR

vbLF

These produce an error that says "Specified value has invalid CRLF characters" I have also tried

\\n

\\r\\n

And it just adds the string literals to my value and does not include a carriage return. On the server side I would like to take what value is included in this header and place into a column in MySQL.

Http Headers must not contain a new line as this is defined as the header separator.

See https://tools.ietf.org/html/rfc7230#section-3 and especially https://tools.ietf.org/html/rfc7230#section-3.2.6 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM