aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Read N Decode HTTP Response From Socket? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Read N Decode HTTP Response From Socket?" Watch "Read N Decode HTTP Response From Socket?" New topic
Author

Read N Decode HTTP Response From Socket?

J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 90
Greetings everyone!



I'm still trying to get know about this topic. he3.
for some reason, yes, I need more feedback for it.



Okay, If I'm not mistaken
I already create a Client socket connected to a server (by domain name)
and then, i got the respond from the server.

To be precise, I want to get the content of it.
And I do passing em, the InputStream into BufferedReader,

but, Once I want to read upon the content.
It seems first written in some Text based, but at the next part
it seems something understand-able

take a look at this.




Is there anyone have ever decode this HTTP Response?
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3164
    
  47

The content-type header of that response states that the body is a GIF image. You are seeing that weird characters as you are reading the image content through a text-based console.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 90
ah!

Yes... sometimes I got it GIF sometimes not also.
It depend upon the respond I received from the actual server.

But still can't get The response as readable. Seems weird.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8

Of course a GIF image isn't "readable", if you meant you expected to get text from it. Nothing weird about that at all.

As Devaka said, the response includes a content-type header. You should look at that, because it tells you what kind of data to expect. Don't expect to get text if the content-type header tells you that the data is an image.
J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 90
ya problems solved!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read N Decode HTTP Response From Socket?