• Post Reply Bookmark Topic Watch Topic
  • New Topic

Partial GET request using Java  RSS feed

 
Rajeev Sampath
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to write a program to get a part of a file using partial get request. So far I couldn't find a way to do that using Java. Any clues?


Thanks and Regards,
Rajeev
 
Aneesh Vijendran
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't get a file object using GET.

You Need POST method & the enctype should definitely be multipart/formdata, as the file is a binary stuff.

Cheers
Aneesh
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aneesh Vijendran wrote:You can't get a file object using GET.


On the contrary, most HTTP requests are GET's, and they usually retrieve file objects (html, gif, jpg, etc.). I think you are thinking of uploading a file.
I haven't seen partial GET functionality in the standard API, but Apache HttpClient appears to support it.
 
Aneesh Vijendran
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well quite political, though!

html/gif/ etc are neither get or post. They jsut come in the response. The request for them might be GET

Cheers
Aneesh
 
Rajeev Sampath
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Thanks both of you for the support.
 
Rajeev Sampath
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For anyone having similar problems:

I was able to do a partial GET request using Apache HTTP client library.
All I had to do was to add a Range header to the get request as follows:

Range: bytes=x-y

x=starting position
y=ending position

I think this can be done using Java's standard libraries since they should have the facility to add headers.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aneesh Vijendran wrote:Well quite political, though!

Not at all. Images, JavaScript and CSS are retrieved using an HTTP GET like Joe said; it's as simple as that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!