Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

what is \n \r in http get requests

843790Nov 9 2007 — edited Nov 9 2007
hi,

last night i struggled a lot with a simple http get request.
apparently the webserver forced me to use http 1.1, which needed a hostname in the get request, which forced me to write two lines in my outputstream (while years ago a simple rq.write(GET /index.htm \n\n) was sufficient.

now it should be:
rq.write("GET /index.htm HTTP/1.1 \r\n");
rq.write("Host: aaa.eu:80 \n\n");

this above works, but i struggled a lot with it to make it work. i tried all possibilities to write it in one line, but nothing worked; the only way to make it work was let the first line end with \r\n and the second line with \n\n...

can someone explain me what the \r\n and the \n\n is???
and maybe someone can tell me why i could not write it in one line???
or tell me how you would have done it
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 7 2007
Added on Nov 9 2007
3 comments
5,816 views