• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Handling PUT Requests on HTTP server.

 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic