Results 1 to 3 of 3
- 10-12-2011, 02:03 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 4
- Rep Power
- 0
Reading A Response From A Web Browses HTTP Request
I have asked a similar question a couple of days ago but I think I did not ask the question very well. I am trying to read the full header of an HTML request. Most of the examples that I read has terminated the while loop when seeing a "GET" returned from the client (Line 5 that is commented out). This is fine if you do not want to read the full header that is being send. My problem is that if I try and read the full head (and / or any data sent in a "POST") this loop hangs just after it see the four byte (13,10,13,10) that signify the end of the header. Which in turn means that I an unable to send a response back the client (which in my case is a web browser). I don't understand how I am to terminate the loop if I want the whole header and data if my socket receives an HTML "POST" request.
Sorry if this question is in the same vain as a previous one that I post. I just need some help understanding what is going on.Java Code:BufferedReader clientInput = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); StringBuilder sbRequest = new StringBuilder(); String sReadLine = null; while ((sReadLine = clientInput.readLine()) != null) { //if(sReadLine.contains("GET")) break; sbRequest.append(sReadLine + "\n"); }
Thanks in advance,
Harold ClementsLast edited by haroldjclements; 10-12-2011 at 02:09 PM. Reason: Typo
- 10-16-2011, 04:50 AM #2
Member
- Join Date
- Oct 2011
- Posts
- 65
- Rep Power
- 0
Re: Reading A Response From A Web Browses HTTP Request
I think problem is after GET code you see the \n.
readLine() method terminates when sees \n(newLine character) in buffer.
HEADER=> GET \number .....
You can only see GET then readline gives null so loop exit.
- 10-16-2011, 04:52 AM #3
Member
- Join Date
- Oct 2011
- Posts
- 65
- Rep Power
- 0
Similar Threads
-
Servlet request and Response Size
By giladma in forum Java ServletReplies: 0Last Post: 09-23-2011, 03:27 PM -
How request and response objects are forwarded
By Matang in forum Java ServletReplies: 3Last Post: 03-28-2011, 12:10 PM -
MDB/JMS Request/Response
By rkands in forum Enterprise JavaBeans (EJB)Replies: 0Last Post: 03-04-2010, 02:38 PM -
HTTP response not read
By SD_Be in forum NetworkingReplies: 1Last Post: 03-10-2009, 04:36 PM -
passively and quickly capturing request/response
By sideswipe091976 in forum NetworkingReplies: 1Last Post: 07-10-2008, 01:01 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks