You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by John Mudd <jo...@gmail.com> on 2006/08/29 03:26:36 UTC
Fwd: unexpected result from HttpClient Post
I used HttpClient to Post to a web page. The ResponseBody though is
the original web page, almost as if I did a Get instead of a Post.
The field I populated is populated in the HTML. It's as if I manually
went to the web page, populated the field and didn't hit Enter or
press the Submit button. Does this sound at all familiar?
Here's my Jython code.
client = HttpClient()
postMethod = PostMethod('http://xyz.com')
postMethod.addParameter('fieldName', '2174131320')
statusCode = client.executeMethod(postMethod)
assert statusCode == HttpStatus.SC_OK
print getResponseBodyAsString()
John
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Fwd: unexpected result from HttpClient Post
Posted by Doug Lochart <dl...@gmail.com>.
Because not everyone uses HttpClient in the way that you wanted to use it.
I myself am using HttpComponents (core) and I am not writing a testing
application.
But thanks for the live headers tip ... that will prove to be invaluable.
Doug
On 8/29/06, John Mudd <jo...@gmail.com> wrote:
>
> Thanks. I installed Live Http Headers in Firefox so now I can see the
> exact headers as I go through the site manually. Hmm, not so easy to
> get a trace to see what HttpClient is sending...
>
> Switched to HttpUnit. Wow, so easy, I'm done. Why would anyone use
> HttpClient when HttpUnit is available?
>
> John
>
>
> On 8/29/06, Roland Weber <RO...@de.ibm.com> wrote:
> > Hello John,
> >
> > > I used HttpClient to Post to a web page. The ResponseBody though is
> > > the original web page, almost as if I did a Get instead of a Post.
> > > The field I populated is populated in the HTML. It's as if I manually
> > > went to the web page, populated the field and didn't hit Enter or
> > > press the Submit button. Does this sound at all familiar?
> > >
> > > Here's my Jython code.
> > >
> > > client = HttpClient()
> > > postMethod = PostMethod('http://xyz.com')
> > > postMethod.addParameter('fieldName', '2174131320')
> > > statusCode = client.executeMethod(postMethod)
> > > assert statusCode == HttpStatus.SC_OK
> > > print getResponseBodyAsString()
> >
> > Posting forms is not as easy as you seem to think.
> > Please follow the instructions in the primer:
> > http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners
> >
> > hope that helps,
> > Roland
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
--
What profits a man if he gains the whole world yet loses his soul?
Re: Fwd: unexpected result from HttpClient Post
Posted by John Mudd <jo...@gmail.com>.
Thanks. I installed Live Http Headers in Firefox so now I can see the
exact headers as I go through the site manually. Hmm, not so easy to
get a trace to see what HttpClient is sending...
Switched to HttpUnit. Wow, so easy, I'm done. Why would anyone use
HttpClient when HttpUnit is available?
John
On 8/29/06, Roland Weber <RO...@de.ibm.com> wrote:
> Hello John,
>
> > I used HttpClient to Post to a web page. The ResponseBody though is
> > the original web page, almost as if I did a Get instead of a Post.
> > The field I populated is populated in the HTML. It's as if I manually
> > went to the web page, populated the field and didn't hit Enter or
> > press the Submit button. Does this sound at all familiar?
> >
> > Here's my Jython code.
> >
> > client = HttpClient()
> > postMethod = PostMethod('http://xyz.com')
> > postMethod.addParameter('fieldName', '2174131320')
> > statusCode = client.executeMethod(postMethod)
> > assert statusCode == HttpStatus.SC_OK
> > print getResponseBodyAsString()
>
> Posting forms is not as easy as you seem to think.
> Please follow the instructions in the primer:
> http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners
>
> hope that helps,
> Roland
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Fwd: unexpected result from HttpClient Post
Posted by Roland Weber <RO...@de.ibm.com>.
Hello John,
> I used HttpClient to Post to a web page. The ResponseBody though is
> the original web page, almost as if I did a Get instead of a Post.
> The field I populated is populated in the HTML. It's as if I manually
> went to the web page, populated the field and didn't hit Enter or
> press the Submit button. Does this sound at all familiar?
>
> Here's my Jython code.
>
> client = HttpClient()
> postMethod = PostMethod('http://xyz.com')
> postMethod.addParameter('fieldName', '2174131320')
> statusCode = client.executeMethod(postMethod)
> assert statusCode == HttpStatus.SC_OK
> print getResponseBodyAsString()
Posting forms is not as easy as you seem to think.
Please follow the instructions in the primer:
http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners
hope that helps,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org