commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed Ludke <edlu...@yahoo.com>
Subject Re: HTTPClient
Date Fri, 27 Jun 2003 14:25:06 GMT
Nate,
 
Hey, I'm no expert so I'm not replying to the forum with this but I have played a little with
the HttpClient component with mixed sucess.  I hate to ask the obvious, but have you checked
out the code samples?  There is one they published within the last few months that was particularly
helpful.  Here's the link in case you haven't already seen it:
 
http://cvs.apache.org/viewcvs/jakarta-commons/httpclient/src/examples/FormLoginDemo.java?rev=1.1&content-type=text/vnd.viewcvs-markup
 
and here's the link to all their code samples:
 
http://cvs.apache.org/viewcvs/jakarta-commons/httpclient/src/examples/
 
The key for me was seeing that you had to manage redirects sort of manually as seen in the
example I pointed out.  
 
There was one other thing that I'm not very sure about (it's been a few weeks since I've worked
with this).  but, out of the things I tried to get stuff working, it sticks in my mind as
having helped.  It was to set the headers to "emulate" one of the well known browsers.  I
seem to recall that the site I was trying to hit wasn't working right so I examined what I
was sending vs. what the browser sent, then I set everything (header stuff) to the match what
it was sending and I was able to get further along (still having some other problems but definately
made progress once I did that).
 
Here's a snippet of what I did:
 

PostMethod method = new PostMethod( aUrl );

method.setUseExpectHeader( false );

method.setFollowRedirects(true);


method.setStrictMode(false);

method.setRequestHeader(new Header("user-agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows
NT 5.1)" ) );

method.setRequestHeader( new Header( "accept", "*/*" ) );

method.setRequestHeader( new Header( "accept-language", "en-us" ) );

method.setRequestHeader( new Header( "accept-encoding", "gzip, deflate" ) );

method.setRequestHeader( new Header( "connection", "Keep-Alive" ) );

method.setRequestHeader( new Header( "cache-control", "no-cache" ) );

 

Hope this helps.  If it does, let me know and maybe I'll post something to the mailing list.

Ed


Nate <nmcminn@charter.net> wrote:

----- Original Message ----- 
From: "Nate" 
To: 
Sent: Thursday, June 26, 2003 8:10 AM


> I have a question for anybody using the HttpClient component. Is there
> anything in particular that has to be done to enable cookies? I have
> already set the policy (tried all 3) in the HttpState that is used by the
> client, but the site I am attempting to communicate with still thinks
> cookies are turned off.
> 

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


---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message