commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Waldhoff, Rodney" <rwald...@us.britannica.com>
Subject RE: HttpClient Usage
Date Wed, 30 Jan 2002 14:07:32 GMT
> So I could just extend the PostMethod class and 
> add a new method like writeRequestBody(HttpState 
> state, HttpConnection conn, String body) that
> simply calls conn.print(body)?  It seems that 
> is all that I need to do, but I wanted to be 
> sure since I have next to no experience with 
> these classes.

Yes, you could do that (also making sure that the Content-Length header is
correctly specified), but that's already provided by the PutMethod
implementation.  If you really want POST not PUT, then extend PutMethod and
override getName() to return "POST" rather than "PUT".  I think that's the
only change you'd need to make.

Alternatively, pretending your "body" is simply a parameter
(PostMethod.setParameter(body,null)) should allow you to do the POST without
changing/extending any of the HTTP Client code, but it feels just a little
like a hack. 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message