0

Just wondering, is this a valid http request, please make a note of leading blank line(s) "\r\n" before the actually request headers.

\r\n\r\nGET / HTTP/1.0\r\n\r\n

Although it works with all the servers (apache, lighttpd, nginx), RFC doesn't mandate anything about leading blank lines and leave it to the implementation.

Thanks

mesibo
  • 3,970
  • 6
  • 25
  • 43

1 Answers1

0

So the standard says each new line should end with \r\n and each request should end with \r\n\r\n

What, at the bare minimum, is required for an HTTP request?

But most servers will handle leading newlines of most types

printf '\rGET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: close\r\n\r\n' |
  nc www.example.com 80
printf '\r\nGET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: close\r\n\r\n' |
  nc www.example.com 80
printf '\r\r\nGET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: close\r\n\r\n' |
  nc www.example.com 80
printf '\n\rGET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: close\r\n\r\n' |
  nc www.example.com 80

About being valid or not, lot of the stuff on net is 100% compliant with RFC standards. You can also see

https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

So a space would create a problem at start but many of the servers would remove leading blank new lines

Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265