You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Kenny Smith <to...@journalscape.com> on 2003/02/19 19:51:19 UTC

[httpclient] How to post data without a parameter name?

Hi all,

I'm porting a legacy perl app to Java and I'm having some trouble 
figuring out how to use the PostMethod class. The legacy app does 
something similar to:

------------ snip ---------------
POST / HTTP/1.1
Host: myhost.atwork.com
Content-Type: text/xml
Content-Length: 3456
Connection: close

<?xml version="1.0"?>

<myroot>
    ...
</myroot>

------------ snip ---------------

However, I can't find any sort of methods on the PostMethod to just set 
the content of the request, only for setting named parameters. Am I 
looking in the wrong place?

Any help is appreciated.
Thanks,
Kenny Smith
JournalScape.com


RE: [httpclient] How to post data without a parameter name?

Posted by Matt Law <ma...@mlbm.co.uk>.
Kenny,

I haven't used 2.0a2 much, so I can't really say. Seems ok tho. If
setQueryString() does the job I'd probably stick with that for now,
especially if you're going to production soon.

Matt.



Re: [httpclient] How to post data without a parameter name?

Posted by Kenny Smith <to...@journalscape.com>.
Hi Matt,

Hmm... the version I have locally is labelled 2.0, but the docs and 
classes in it are vastly smaller than what's on the website. :/ How 
stable is 2.0a2?

I just figured out that I can use HttpMethod's setQueryString() and it 
will do what I want, but I'd rather use the newer API.

Kenny

Matt Law wrote:

> It's in PostMethod, but the docs I'm looking at are HttpClient 2.0 on
> the site. I don't have an older copy to hand.
>
> Matt.
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


RE: [httpclient] How to post data without a parameter name?

Posted by Matt Law <ma...@mlbm.co.uk>.
It's in PostMethod, but the docs I'm looking at are HttpClient 2.0 on
the site. I don't have an older copy to hand.

Matt.





Re: [httpclient] How to post data without a parameter name?

Posted by Kenny Smith <to...@journalscape.com>.
Hi Matt,

Thanks for the response. What class is that defined in? I tried to find 
something like that but came up empty handed.

Kenny

Matt Law wrote:

> Try setRequestBody().... Takes a string, inputstream etc.



RE: [httpclient] How to post data without a parameter name?

Posted by Matt Law <ma...@mlbm.co.uk>.
Try setRequestBody().... Takes a string, inputstream etc.

Matt.

-----Original Message-----
From: Kenny Smith [mailto:tomcat-user@journalscape.com] 
Sent: Thursday, 20 February 2003 5:51 AM
To: commons-user@jakarta.apache.org
Subject: [httpclient] How to post data without a parameter name?


Hi all,

I'm porting a legacy perl app to Java and I'm having some trouble 
figuring out how to use the PostMethod class. The legacy app does 
something similar to:

------------ snip ---------------
POST / HTTP/1.1
Host: myhost.atwork.com
Content-Type: text/xml
Content-Length: 3456
Connection: close

<?xml version="1.0"?>

<myroot>
    ...
</myroot>

------------ snip ---------------

However, I can't find any sort of methods on the PostMethod to just set 
the content of the request, only for setting named parameters. Am I 
looking in the wrong place?

Any help is appreciated.
Thanks,
Kenny Smith
JournalScape.com


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org