Win a copy of Rust Web Development this week in the Other Languages forum!

Michael Ramirez

Greenhorn
+ Follow
since Jul 04, 2011
Michael likes ...
Google Web Toolkit Eclipse IDE Firefox Browser
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Michael Ramirez

Its up to you what is modeled as a class and what isn't.

With your example you might create a "Class" object, and it could contain "Student" objects.

10 years ago
Hello all,

I'm new to the ranch but I'm hoping you guys can help me out with a small I/O problem.
I'm trying to learn a bit more about HTTP protocol, so I wrote some Java code to send & receive text HTTP messages over Sockets.

For example, I might send: "GET /somepath/somefile.html HTTP/1.0\r\n\r\n", and listen for a response from the web server.
However, I run into problems when I request a non-text file (like an Image), I can't figure out how to process it. A website I'm reading states:

An HTTP message may have a body of data sent after the header lines. In a response, this is where the requested resource is returned to the client (the most common use of the message body)


  • If its not text, how do I process the body? Do I just read raw bytes from the InputStream?
  • How can I tell where the 'Header Line' ends & the 'Message Body' starts? Do I simply check for "\r\n\r\n"?
  • How do I determine the byte length of the content? Can I trust the "Content-Length" field? or Do I loop until EOF?

  • I can't get my program to work with non text-files. I tried reading the HTTP RFC, but it didn't help much.
    -Mike

    http://en.wikipedia.org/wiki/HTTP_body_data
    http://www.jmarshall.com/easy/http/#messagebody
    10 years ago