Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Handling PUT Requests on HTTP server.  RSS feed

 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I'm creating a simple HTTP client and Server that supports GET and PUT requests. For the client side I'm using a DataOutputStream to send the request and the file for a PUT request. I'm having trouble retrieving this on the server side though. I attempted to use a BufferedReader and I read the first line of the response, and then I open a DataInputStream and try to read the file but it's not working. Is this the wrong approach for implementing a PUT request? The GET is working great. If anyone has any ideas or could point to some resource I'd appreciate it.

Thanks for your time.
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is really a problem with IO blocking. I send the file from the client side without a problem, but on the server-side with the following code:


inFromClient is a BufferedReader. My problem is that I never come to the value of -1, after the last line of the file is sent, this loop just blocks. Anyone have any ideas how to prevent this? Thanks.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't done PUT but here's my code for POST. It's called after reading the headers to a blank line if the verb is post and it is not multi-part. It relies on the content size header which works in my environment but may not be safe in the real world:

Is PUT significantly different?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!