Page 1 of 2 12 LastLast
Results 1 to 20 of 22
Like Tree2Likes

Thread: where go/goes the blank line(s) at the HTTP request and the response

  1. #1
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default where go/goes the blank line(s) at the HTTP request and the response

    What is not totally clear to me is where and when there is a "blank line" at the request-response pattern?
    a) Is the line present at BOTH the request and the response?
    b) And when so it ALWAYS found between 2) and 3)
    c) And when (the optional?) block 3) is NOT present still one has to insert that blank line?


    Communication with an HTTP server follows a request-response pattern: one stateless request followed by one stateless response.
    Each HTTP request has two or three parts:
    1) A startline containing the HTTP method and a path to the resource on which the method should be executed
    2) A header of name-value fields that provide meta-information such as authentica‐ tion credentials and preferred formats to be used in the request
    3) A request body containing a representation of a resource (POST and PUT only) There are four main HTTP methods, four verbs if you will, that identify the operations that can be performed:

    • GET
    • POST
    • PUT
    • DELETE
    Last edited by willemjav; 04-17-2014 at 09:07 AM.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,907
    Rep Power
    5

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    And more non-Java questions. At least state the source of that block of text.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Hi,

    if you want to be sure that your messages / responses are standard conform, then I would always check the standard itself:
    RFC2616 is defining the http 1.1 protocoll and section 4 describes the messages:
    HTTP/1.1: HTTP Message
    generic-message = start-line
    *(message-header CRLF)
    CRLF
    [ message-body ]
    start-line = Request-Line | Status-Line

    So you always have a start line (which can be a request or status line).
    Then you can have message headers
    Then you have a blank line.
    Then comes optional a message-body.

    So you always have a blank line that indicates the end of the header. You cannot say which linenumber it is so a "line 2 or 3" does not make sense.

    Regarding empty lines at the beginning: It is recommend inside the status that (a) leading CRLF should be ignored by servers.

    With kind regards,

    Konrad
    Tolls likes this.

  4. #4
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    to gimbal2 "At least state the source of that block of text.":
    Java Network Programming 4th edition (do you like that book and you think it is good?)

    to Konrad (thanks konrad): The numbers 1), 2) and 3) are not line numbers they are blocks:
    1) the lines:
    - in case of request the single line: "GET /index.html HTTP/1.1"
    -in case of server response "HTTP/1.1 200 OK "
    2) a multi line block of name/ value like:
    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0)
    Gecko/20100101 Firefox/20.0[*]
    Host: en.wikipedia.org
    Connection: keep-alive
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    3) An optional block of

    Java Code:
    <html> 
    <head> 
    <title> A Sample HTML file </title>
    </head> 
    <body> 
    The rest of the document goes here 
    </body> </html>
    Only at the response? or also at the request?

    So that blank line goes between block 2) and 3) with or without block 3) right?

    (pls don't be mad gimbal2)

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,907
    Rep Power
    5

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    I'm mad, but not angry. I'm only trying to make you see the holes in your questions in the hope that in the future you will think first about how you present your questions; you should not be making people guess as to what is in your brain at the time of writing. Provide context.

    Konrad's answer holds the key; if you want to know something about the HTTP protocol, look at the RFC about that topic.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Questions are asked, when not in a rhetorical manner, because of a lack of understanding, right?
    So that fact logically includes certain "holes"!
    and btw I did thank Konrad.
    And about "more non-Java questions", my question is Servlet related (see the Thread category) so it is right at the spot.

    It is almost weekend, gimbal2......

  7. #7
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Or are you hinting that I should think even much harder so I do not need to come to this forum
    to ask my question?
    But now I ask you gimbal2 what is the sense of this forum?

  8. #8
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    yes, you got it correct.
    Between the Blocks 2 and 3 you have to put a CRLF ("newline" - but that words mean different things on different platforms.) and it does not matter if you have a block 3 or not.

    Just look at the possible communication:

    A client connects to the server and brings block 1 and block 2 but no CRLF. The server cannot know if more parts of block 2 will come or not. If you close the connection, the server will not know if you did it by purpuse (because the transmission was done) or if the connection was lost.
    So without that CRLF you will run into trouble.

    And now you might wonder how this problem is solved with block 3. The answer in this is the content-length inside block 2. If you want to transmit data, then you simply tell the other side how much data you will send. (It is not something you have to do. But if you do not give this parameter, then you will never know if a transmission was successfull or not. Maybe something you experienced in the past, too:
    When you download some content then you normaly get a bar that tells you: xxx bytes of yyyyy downloaded. Great. The server gave us the data.
    But sometimes you do not get such a bar and instead you just get the information xxx bytes downloaded. Then the server didn't give the content length and now the client saves what it gets. And if the connection breaks for any reason, then the download is done (and always successfull. Great! I like stuff that never fail. :) )

    With kind regards,

    Konrad
    willemjav likes this.

  9. #9
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Great info Konrad and Yes I am into studying all this but it is quite a lot of info to digest....
    Is that Oriely book useful I mentioned to gimbal2 (Java Network Programming 4th edition), you think?
    You know I depend much on "believing" that book for the moment?

    I wondered just one other thing, how would you measure the number of bytes to list at:
    Content-Length: ???

    or does the computer do that for you?
    Last edited by willemjav; 04-17-2014 at 10:30 AM.

  10. #10
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,907
    Rep Power
    5

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Quote Originally Posted by willemjav View Post
    But now I ask you gimbal2 what is the sense of this forum?
    Again you expect me to read your mind. What does 'this forum' mean inside your head Willemjav? The site? The servlet subforum? What?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  11. #11
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    simply, asking questions (under servlet) related to servers used by java
    But what you think about that book (that was a clear/ concrete question), gimbal2

  12. #12
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Hi,

    it always depends on what you really want to do. The book is quite nice if you want to develop networking apps (apps, where you really work with sockets). Business applications normaly do not need something like that because you work on a "higher level". So if you develop a web service then you normaly do not work on a socket basis. Instead you use classes that hide everything. (It is like building a website. You develop the content but you do not start to build a webserver!)

    Regarding the content length: Did you read chapter 4.4? That describes the possibility of content. content-length is not always required. But when used it should contain the transfer-length of the body (After all encoding stuff!). So you could build the data that you want to send and then see how many bytes you got in the buffer. And then put that as content-length.

    With kind regards,

    Konrad

  13. #13
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,907
    Rep Power
    5

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Quote Originally Posted by willemjav View Post
    simply, asking questions (under servlet) related to servers used by java
    You're NOT asking that, you're asking about the HTTP protocol. You only think you can make this reasoning because you were reading a book about Java servers and web technology, but that only became clear after I asked you to provide the source of your question. Remember that? If not: its higher up in the thread.

    But what you think about that book (that was a clear/ concrete question), gimbal2
    You assume I have read every book in existence? You know there are multiple books on the same topic right? The chance is quite high that I read another book.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  14. #14
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Perfect, Konrad, indeed I started reading some practical stuff concerning Servlets that
    basically say: do this do that but not tell you why. I´d like to go deeper and the book
    is (therefor) a good pick. And yes I´d like to build web applications but also like to
    understand what I am doing. Concerning that book, there is 4th edition which took out
    some of the socket content of the 3th (using high level classes such as URLConnection)
    and especially the chapter of Swing and HTML is totally remodelled because that was very
    complex and confusing (man I had a hard time understanding that). I still have some holes
    in my understanding of this material and I still do not have yet a good over-view of its possibilities.
    Measuring a buffer is a good hint thank you for that one, great answer, Konrad!
    Last edited by willemjav; 04-17-2014 at 12:51 PM.

  15. #15
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Gimbal2, your way of thinking is highly compartmentalized which I see as a problem.
    It is impossible to run a servlet only on pure Java code!
    So you need protocols like HTTP to run one and those questions should be
    addressed (certainly at this forum) I believe!

  16. #16
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,907
    Rep Power
    5

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    You were/are not asking a question about servlets. You're asking a question about the HTTP protocol. You can try to insult me and belittle me all you want and I don't even know why, I'm only answering questions you're pelting at me. You can ask off-topic questions all you want, all I ask is that you do so by providing the proper context so that we may understand what you're after. See the trend? I say A, you invent story B around that.
    Last edited by gimbal2; 04-17-2014 at 01:12 PM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  17. #17
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    I give up, you won!

  18. #18
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,907
    Rep Power
    5

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    No I give up, I'll ignore your posts from now on. People like you give me a high blood pressure.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  19. #19
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Dear Gimbal2

    I have a rather Intuitive approach towards Java programing and I know that is not very common. There are those type of boys that destroy their toys, all the time, because they want to look inside and see how things work (most parents do not understand that fact!). When they finally try to put the pieces together and they can't (what usually happens) they might get into reading books entitled: "How to Assemble….."

    I, at first, most of the time, stumble into new things concerning Java programming (You know, like getting a new VCR set out of the box and pushing all buttons before reading the manual). When this happens you usually jump all over me to demand clarity and good phrased questions, focussed in the topic only….. which I can't respond to…. and than you get mad…..

    We are simply on different frequencies?

    You see Gimbal2 I am very concerned about the fact that men is merging with machines (physically and spiritually) and I follow that discussion called "Transhumanism" with great interest and think basically that Raymond Kurzweil is an idiot! I believe even that Chemtrails are part of that agenda.

    You see machines meanly follow protocols, but humans most of the time NOT and Governments do not like that fact (remember our recent NSA-offtopic-talk). Governments would like people more and more to act like machines that stay on topics (their topics) but most humans wont do that! (Government is derived from Latin "Guverno, Guvernare" = "to control" and the noun "Mens, Mentis" = mind which assembles to: Mind-Control)

    Now YOU have a problem Gimbal2 because you would like to argument that I need to stay on subject and therefor need to find myself another forum, but you can't! Now I have a problem because I might need your excellent expertise on Java Web subjects and I wont!

    I feel sad because I do not want to raise your blood pressure and cause you health problems.

    I thank you for all your responses and I hope you will rethink your decision because I always enjoyed debating you!

    greatings willemjav

  20. #20
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    938
    Rep Power
    2

    Default Re: where go/goes the blank line(s) at the HTTP request and the response

    Wow, transhumanism, chem trails, mind-control. I guess I missed that part of the HTTP spec :)

    HTTP 1.1 Error 666: Tinfoil hat not found
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

Page 1 of 2 12 LastLast

Similar Threads

  1. java udp request response mismatch
    By developer89 in forum JavaServer Pages (JSP) and JSTL
    Replies: 7
    Last Post: 10-10-2013, 04:44 PM
  2. Reading A Response From A Web Browses HTTP Request
    By haroldjclements in forum Networking
    Replies: 2
    Last Post: 10-16-2011, 04:52 AM
  3. Servlet request and Response Size
    By giladma in forum Java Servlet
    Replies: 0
    Last Post: 09-23-2011, 03:27 PM
  4. How request and response objects are forwarded
    By Matang in forum Java Servlet
    Replies: 3
    Last Post: 03-28-2011, 12:10 PM
  5. MDB/JMS Request/Response
    By rkands in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 03-04-2010, 02:38 PM

Posting Permissions

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