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 "Pullen, Matthew" <mp...@digitalmotorworks.com> on 2006/01/26 01:25:07 UTC

Posting behind a proxy

I am trying to test the posting to a remote site using HTTPClient. I am
continually failing and was hoping someone could give me a pointer as to
what I am doing wrong. I have not had a chance to try it from outside
the proxy, so that may have something to do with it, but I am not sure.
It gets the redirect back to the login page, which looks like a failure
to log in to me. I am stumped.

 

TIA,

Matthew

 

Code Snipet:

 public static void testPost() throws Exception {

        HttpClient client = new HttpClient();

 

        client.getHostConfiguration().setProxy("proxy.myproxy.com",
8000);

        

        PostMethod post = new
PostMethod("https://www.netflix.com/Login");

        post.addParameter(new NameValuePair("email", "myemail"));

        post.addParameter(new NameValuePair("password1", "mypassword"));

        post.addParameter(new NameValuePair("RememberMe", "True"));

        post.addParameter(new NameValuePair("SubmitButton", "Click Here
to Continue"));

         

        try {

            int status = client.executeMethod( post );

            System.out.println("post status:"+ status);

            String redirectLocation;

            Header locationHeader = post.getResponseHeader("location");

            if (locationHeader != null) {

                redirectLocation = locationHeader.getValue();

                System.out.println("redirectLocation:"+
redirectLocation);

            } else {

 

            }

        } finally {

            post.releaseConnection();

        }

}

 

A similar straight form, posted from my local location works just fine:

<http>

<body>

<form METHOD="POST" ACTION="https://www.netflix.com/Login" >

Email: <input TYPE="TEXT" SIZE="28" NAME="email" value="myemail"><BR>

Remember ME: <INPUT type="text" id="RememberMe" name="RememberMe"
value="True" ><BR>

Password: <input TYPE="PASSWORD" SIZE="15" NAME="password1"
value="mypass" maxlength=60><BR>

<input class="core-button" type="submit" value="Click Here to Continue"
name="SubmitButton">

</form>

</body>

</html>

 

J. Matthew Pullen

Digital Motorworks

(512) 692-1126

 



This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system.

Re: Posting behind a proxy

Posted by Miguel A Paraz <mp...@gmail.com>.
On 1/26/06, Pullen, Matthew <mp...@digitalmotorworks.com> wrote:
> I am trying to test the posting to a remote site using HTTPClient. I am
> continually failing and was hoping someone could give me a pointer as to
> what I am doing wrong. I have not had a chance to try it from outside
> the proxy, so that may have something to do with it, but I am not sure.
> It gets the redirect back to the login page, which looks like a failure
> to log in to me. I am stumped.

I believe the Netflix page assumes a live browser with cookie support.
I tried a plain GET on https://www.netflix.com/Login - it redirects
to:

Location: http://www.netflix.com/Login?tcw=1&cqs=

Along with a whole lot of cookies being set. I think a successful
login requires the cookies to be set.

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