hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sarwar_R...@3com.com
Subject Re: PostMethod and Digest authentication
Date Sat, 26 Mar 2005 17:12:49 GMT




Hi Oleg...
Thanks for this - worked like a charm :-)

-Sarwar




Oleg Kalnichevski <olegk@apache.org> on 03/22/2005 05:19:47 PM

Please respond to "HttpClient Project" <httpclient-dev@jakarta.apache.org>

Sent by:    Oleg Kalnichevski <olegk@apache.org>


To:    HttpClient Project <httpclient-dev@jakarta.apache.org>
cc:
Subject:    Re: PostMethod and Digest authentication


Hi Sarwar

It's all quite simple. The digest authentication scheme requires the
target server to send the so called challenge which the client in its
turn is supposed to respond to. I *assume* the server you are using only
sends an authentication challenge in response to GET methods.

You may try the following work-around. Authenticate using GET method
first, get the AuthScheme instance used by the GET method to
authenticate with the server, manually generate a digest response, and
send the resulting authentication response with the all the subsequent
POST methods.

These Javadocs should get you going in the right direction

http://jakarta.apache.org/commons/httpclient/3.0/apidocs/org/apache/commons/httpclient/HttpMethod.html#getHostAuthState()

http://jakarta.apache.org/commons/httpclient/3.0/apidocs/org/apache/commons/httpclient/auth/AuthState.html#getAuthScheme()

http://jakarta.apache.org/commons/httpclient/3.0/apidocs/org/apache/commons/httpclient/auth/AuthScheme.html#authenticate(org.apache.commons.httpclient.Credentials,%20org.apache.commons.httpclient.HttpMethod)


Hope this helps

Oleg


On Tue, 2005-03-22 at 16:26 -0600, Sarwar_Raza@3com.com wrote:
>
>
>
> Hi..
> I'm having trouble with the HttpClient 3.0 Post functionality.
> Here's what I'm attempting to do. I need to post a file to a web server
on
> an embedded device. The device uses MD5 digest authentication, and I have
> been able to authenticate sucessfully using the GetMethod.
>
> However, when I attempt to use the PostMethod (I'm doing a multipart file
> upload), the authentication header is never added to the outgoing HTTP
> request.
>
> I see the following the the debug log:
> 2005/03/22 15:03:16:058 CST [DEBUG] DefaultHttpParams - Set parameter
> http.auth.scheme-priority = [Digest]
>
> So I know the auth scheme is set right. However, unlike in the case with
> the HTTP GET, I never see a challenge, and no auth header generated. Do I
> have to do something special to trigger this?
> I modifed the MultipartFileUploadApp demo to use Digest authentication
and
> added logging traces (below). Can anyone kindly shed light on what may be
> going on?
>
> Thanks
> -Sarwar
> --------------------
>
> 2005/03/22 15:03:16:058 CST [DEBUG] DefaultHttpParams - Set parameter
> http.auth.
> scheme-priority = [Digest]
> 2005/03/22 15:03:16:058 CST [DEBUG] DefaultHttpParams - Set parameter
> http.conne
> ction.timeout = 5000
> 2005/03/22 15:03:16:088 CST [DEBUG] HttpConnection - Open connection to
> 152.67.1
> 23.50:80
> 2005/03/22 15:03:16:128 CST [DEBUG] header - >> "POST /Forms/FileUpdate1
> HTTP/1.
> 1[\r][\n]"
> 2005/03/22 15:03:16:128 CST [DEBUG] HttpMethodBase - Adding Host request
> header
> 2005/03/22 15:03:16:148 CST [DEBUG] header - >> "User-Agent: Jakarta
> Commons-Htt
> pClient/3.0-rc1[\r][\n]"
> 2005/03/22 15:03:16:148 CST [DEBUG] header - >> "Host: 152.67.123.50
> [\r][\n]"
> 2005/03/22 15:03:16:148 CST [DEBUG] header - >> "Content-Length:
> 2335298[\r][\n]
> "
> 2005/03/22 15:03:16:148 CST [DEBUG] header - >> "Content-Type:
> multipart/form-da
> ta; boundary=RtUiCJN5BC4hs8SnPQ2qsPOh-7PptKFXlQTTTIw[\r][\n]"
> 2005/03/22 15:03:16:168 CST [DEBUG] header - >> "[\r][\n]"
> 2005/03/22 15:03:24:180 CST [DEBUG] EntityEnclosingMethod - Request body
> sent
> 2005/03/22 15:03:24:270 CST [DEBUG] header - << "HTTP/1.1 400 Bad
> Request[\r][\n
> ]"
> 2005/03/22 15:03:24:270 CST [DEBUG] header - << "Content-Length:
0[\r][\n]"
> 2005/03/22 15:03:24:270 CST [DEBUG] header - << "Server:
> Allegro-Software-RomPag
> er/3.10[\r][\n]"
> 2005/03/22 15:03:24:280 CST [DEBUG] HttpMethodBase - Resorting to
protocol
> versi
> on default close connection policy
> 2005/03/22 15:03:24:280 CST [DEBUG] HttpMethodBase - Should NOT close
> connection
> , using HTTP/1.1
> 2005/03/22 15:03:24:280 CST [DEBUG] HttpConnection - Releasing connection
> back t
> o connection manager.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
>


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




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


Mime
View raw message