Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

Jakarta problem

Thread view: 
slippymississippi@yahoo.com - 24 Mar 2006 00:40 GMT
I have this document that I would like to send via HTTP Post.  However,
the receiving application expects the content data to be sent as a
parameter... and the content data can be hundreds of megabytes large.

Does there exist an HTTP Client tool that allows you to stream the post
request, rather than loading the request into memory up front?
Oliver Wong - 24 Mar 2006 18:33 GMT
> I have this document that I would like to send via HTTP Post.  However,
> the receiving application expects the content data to be sent as a
> parameter... and the content data can be hundreds of megabytes large.

   When you say "as a parameter", do you mean GET? If so, you may be out of
luck. I believe there's a limit on the length of an HTTP URL.

   - Oliver
slippymississippi@yahoo.com - 24 Mar 2006 18:46 GMT
> When you say "as a parameter", do you mean GET?

No, POST.  I'm assuming that Jakarta knows enough about post to bury
any huge parameter value in the body of the post, right?
Roedy Green - 24 Mar 2006 19:11 GMT
>No, POST.  I'm assuming that Jakarta knows enough about post to bury
>any huge parameter value in the body of the post, right?

with post, all parameters go in the body.

Various sites, e.g. webring, Opera, let you upload photos. You might
sniff what is going on there to use as a model.

see http://mindprod.com/jgloss/sniffer.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Oliver Wong - 24 Mar 2006 19:17 GMT
>> When you say "as a parameter", do you mean GET?
>
> No, POST.  I'm assuming that Jakarta knows enough about post to bury
> any huge parameter value in the body of the post, right?

   Okay, so when you say "I have this document that I would like to send
via HTTP Post.  However, the receiving application expects the content data
to be sent as a parameter", why the "however"? What's preventing you from
simply using POST?

   - Oliver
slippymississippi@yahoo.com - 24 Mar 2006 20:10 GMT
> What's preventing you from simply using POST?

"... the content data can be hundreds of megabytes large."

This is going to be a threaded application handling multiple requests,
I don't think loading up Java String objects with several hundred
megabytes, and passing them into a PostMethod object using Jakarta's
addParameter method is going to fly.
Oliver Wong - 24 Mar 2006 20:54 GMT
>> What's preventing you from simply using POST?
>
[quoted text clipped - 4 lines]
> megabytes, and passing them into a PostMethod object using Jakarta's
> addParameter method is going to fly.

   I looked all over http://jakarta.apache.org/httpcomponents/index.html 
and couldn't find an API reference, so I don't know what's available to you.
If I were doing this, I'd do it manually, forming the HTTP request header,
sending it to the socket, then maybe read 1024 bytes a at time from the
file, send that through the socket, read another 1024 bytes, send it, and so
on.

   If Jakarta really "forces" you pre-load the entire file in memory, and
if that goes against your requirements, I guess you have no choice but to
dump Jakarta; at least for this particular feature.

   - Oliver
slippymississippi@yahoo.com - 24 Mar 2006 21:17 GMT
> I looked all over

Yeah, I thought it was kinda wacky that they hide the javadocs from
you.  You have to drill down into the developer's section to get to the
javadocs, IIRC.

Thanks!
Oliver Wong - 24 Mar 2006 22:06 GMT
>> I looked all over
>
> Yeah, I thought it was kinda wacky that they hide the javadocs from
> you.  You have to drill down into the developer's section to get to the
> javadocs, IIRC.

See
http://svn.apache.org/repos/asf/jakarta/httpcomponents/trunk/http-core/src/examp
les/org/apache/http/examples/ElementalHttpPost.java


   You can provide an InputStream to the request. So provide a
FileInputStream.

   - Oliver
Roedy Green - 24 Mar 2006 22:13 GMT
>    I looked all over http://jakarta.apache.org/httpcomponents/index.html 
>and couldn't find an API reference,

see http://jakarta.apache.org/commons/httpclient/apidocs/index.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Oliver Wong - 24 Mar 2006 22:25 GMT
>>    I looked all over http://jakarta.apache.org/httpcomponents/index.html
>>and couldn't find an API reference,
>
> see http://jakarta.apache.org/commons/httpclient/apidocs/index.html

   Thanks. I see now the API for PostMethod, and its insistence of
receiving pairs of strings as ("name","value) pairs that Slippy was
complaining about.

   I took a look at the code at
http://svn.apache.org/repos/asf/jakarta/httpcomponents/trunk/http-core/src/examp
les/org/apache/http/examples/ElementalHttpPost.java

to see how they did things differently, and it looks like they are using the
org.apache.http.message.HttpPost and org.apache.http.HttpEntity classes
which don't see to be covered by the "org.apache.commons.httpclient" set of
javadocs.

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.