multipart/form-data in 4.0

View: New views
4 Messages — Rating Filter:   Alert me  

multipart/form-data in 4.0

by David Byrne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm having problems figuring out how multipart/form-data entities are implemented in components 4.0. Because UrlEncodedFormEntity exists, I expected an analogue of MultipartRequestEntity from 3.x. Please let me know what I'm missing.

If it hasn't been implemented yet, is it on the road map?

Thanks,
David Byrne





      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@...
For additional commands, e-mail: httpcomponents-dev-help@...


Re: multipart/form-data in 4.0

by Roland Weber :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello David,

> I'm having problems figuring out how multipart/form-data entities
> are implemented in components 4.0.

They're not.

> Because UrlEncodedFormEntity exists, I expected an analogue of
> MultipartRequestEntity from 3.x.

We need URL encoding for query strings anyway, so it's not a big
deal to use it in an entity. Formatting multipart entities is a
much more complex beast.

> If it hasn't been implemented yet, is it on the road map?

Not really. For our core activity "HTTP", multipart is somewhat
out of scope. We'd love to use multipart code maintained by some
other project for which it is in scope, but I'm not aware of any.
We tried to move the multipart code to commons-codec a few years
ago, but I didn't take off there. Oleg recently mentioned another
project that has multipart parsing code and might be interested
in our multipart formatting code. I don't know the current status
on that.
If we should extend our activities to WebDAV, multipart would
move into scope. But that is _very_ far at the horizon and may
never happen at all.

When HttpClient 4.0 goes beta and we have a stable API to work
with, I was planning to address the multipart problem somehow.
Either as a wrapper from the 4.0 HttpEntity [1] interface to the
3.1 RequestEntity [2] interface, or by moving the multipart code
into an unsupported 'contrib' package, or both. The wrapper
would of course also be in an unsupported 'contrib' package.

For the time being, I recommend to implement a wrapper so
you can use 3.1 entities for sending with the 4.0 API.
Here's a short run-down on how to map the methods:

(sending)
getContentLength   -> getContentLength
getContentType     -> getContentType
isChunked          -> (getContentLenght < 0L)
isRepeatable       -> isRepeatable
writeTo            -> writeRequest

(receiving, not supported)
consumeContent     -> UnsupportedOperationException
getContentEncoding -> null
getContent         -> UnsupportedOperationException
isStreaming        -> false


hope this helps,
  Roland

[1]
http://jakarta.apache.org/httpcomponents/httpcomponents-core/httpcore/apidocs/org/apache/http/HttpEntity.html
[2]
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/methods/RequestEntity.html

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@...
For additional commands, e-mail: httpcomponents-dev-help@...


Re: multipart/form-data in 4.0

by David Byrne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That makes sense. Multipart seems like a pain to implement, so I'm not surprised.

Thanks for the quick response and the nice library.

David

----- Original Message ----
From: Roland Weber <ossfwot@...>
To: HttpComponents Project <httpcomponents-dev@...>
Sent: Friday, December 7, 2007 9:45:18 PM
Subject: Re: multipart/form-data in 4.0


Hello David,

> I'm having problems figuring out how multipart/form-data entities
> are implemented in components 4.0.

They're not.

> Because UrlEncodedFormEntity exists, I expected an analogue of
> MultipartRequestEntity from 3.x.

We need URL encoding for query strings anyway, so it's not a big
deal to use it in an entity. Formatting multipart entities is a
much more complex beast.

> If it hasn't been implemented yet, is it on the road map?

Not really. For our core activity "HTTP", multipart is somewhat
out of scope. We'd love to use multipart code maintained by some
other project for which it is in scope, but I'm not aware of any.
We tried to move the multipart code to commons-codec a few years
ago, but I didn't take off there. Oleg recently mentioned another
project that has multipart parsing code and might be interested
in our multipart formatting code. I don't know the current status
on that.
If we should extend our activities to WebDAV, multipart would
move into scope. But that is _very_ far at the horizon and may
never happen at all.

When HttpClient 4.0 goes beta and we have a stable API to work
with, I was planning to address the multipart problem somehow.
Either as a wrapper from the 4.0 HttpEntity [1] interface to the
3.1 RequestEntity [2] interface, or by moving the multipart code
into an unsupported 'contrib' package, or both. The wrapper
would of course also be in an unsupported 'contrib' package.

For the time being, I recommend to implement a wrapper so
you can use 3.1 entities for sending with the 4.0 API.
Here's a short run-down on how to map the methods:

(sending)
getContentLength   -> getContentLength
getContentType     -> getContentType
isChunked          -> (getContentLenght < 0L)
isRepeatable       -> isRepeatable
writeTo            -> writeRequest

(receiving, not supported)
consumeContent     -> UnsupportedOperationException
getContentEncoding -> null
getContent         -> UnsupportedOperationException
isStreaming        -> false


hope this helps,
  Roland

[1]
http://jakarta.apache.org/httpcomponents/httpcomponents-core/httpcore/apidocs/org/apache/http/HttpEntity.html
[2]
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/methods/RequestEntity.html

---------------------------------------------------------------------
To unsubscribe, e-mail:
 httpcomponents-dev-unsubscribe@...
For additional commands, e-mail:
 httpcomponents-dev-help@...






      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@...
For additional commands, e-mail: httpcomponents-dev-help@...


Re: multipart/form-data in 4.0

by olegk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sat, 2007-12-08 at 05:45 +0100, Roland Weber wrote:

> Hello David,
>
> > I'm having problems figuring out how multipart/form-data entities
> > are implemented in components 4.0.
>
> They're not.
>
> > Because UrlEncodedFormEntity exists, I expected an analogue of
> > MultipartRequestEntity from 3.x.
>
> We need URL encoding for query strings anyway, so it's not a big
> deal to use it in an entity. Formatting multipart entities is a
> much more complex beast.
>
> > If it hasn't been implemented yet, is it on the road map?
>
> Not really. For our core activity "HTTP", multipart is somewhat
> out of scope. We'd love to use multipart code maintained by some
> other project for which it is in scope, but I'm not aware of any.
> We tried to move the multipart code to commons-codec a few years
> ago, but I didn't take off there. Oleg recently mentioned another
> project that has multipart parsing code and might be interested
> in our multipart formatting code. I don't know the current status
> on that.

The project is Apache mime4j

http://james.apache.org/mime4j/index.html

I am not sure, though, they want to expand the scope of the library to
include MIME formatting code. They did not seem to sound too
enthusiastic when I suggested we might contribute the multipart encoder
from HttpClient.

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@...
For additional commands, e-mail: httpcomponents-dev-help@...