Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

You're not sending an HTTP response, though. You're sending a CGI response. What server are you using? Apache accepts LF.

Interesting. I sent a curl request to my Apache server, and I sniffed the response using Wireshark, and Apache performs conversions on the characters that a cgi script uses to terminate the headers. Here are the conversions that I observed:

  1. "\n\n" => "\r\n\r\n"
  2. "\r\n\r\n" => "\r\n\r\n"
  3. "\r\r" => Internal sever error
  4. "\n\r\n\r" => "\r\n\r\n" plus a \r to start the body of the request

I think Apache is following the dictum: "Be permissive in what you allow, but be strict in what you do." Likewise, I am going to be strict in what I do, and I'm not going to rely on a server to convert newlines to the HTTP 1.1 spec.

(I think it also accepts CRLF.)

It seems obvious to me that any http server would accept the header termination characters in the HTTP 1.1 spec? Why the hesitation? Were you speculating that "\r\n\r\n" might get converted to "\r\r\n\r\r\n"?

In reply to Re: CGI: newlines, write exactly "\r\n" to end the headers, then turn off binmode by 7stud
in thread CGI: newlines, write exactly "\r\n" to end the headers, then turn off binmode by 7stud

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-06-18 07:00 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.