GET request with request and authorization http authorization

I have a java service that I need to use (can't change it) and a web server that uses HTTP digest authorization. I am using HttpWebRequest to communicate with the server (using the GET method). NetworkCredentials are required for authentication. But the GetResponse () call generates a 400 (Bad Request) error.

Address: http://info.server.com/someFolder/servlet.do?cmd=get_infoΒΆm=value

Example request (not complete, only relevant things):

GET / someFolder / servlet.do? Cmd = get_info & param = value HTTP / 1.1

Host: info.server.com

Answer: 401 Authorization required

Second query:

GET / someFolder / servlet.do? Cmd = get_info & param = value HTTP / 1.1

Host: info.server.com

Authorization: Digest ... uri = "/someFolder/servlet.do" ... (not the full title explicitly)

Second answer: 400 Bad request

I tried this request with web browsers (IE, Firefox) and it works, but it seems that the browser has put the entire uri request in the uri parth of the Authorization header, while HttpWebRequest formats the header as above. Does anyone know how to get the HttpWebRequest to put the entire uri in the authorization header? Or maybe there is another problem in this issue?

Thanks for the help!

0


a source to share


2 answers


This article from 4GuysFromRolla describes the implementation of basic and digest authentication for HttpWebRequest.



http://www.4guysfromrolla.com/articles/102605-1.aspx

0


a source


We have the same problem and traced it back to the url in the authorization header. It looks like the HttpWebRequest is only sending the hostname and not the full URL. He omits:

?cmd=get_info&param=value

      



from the url. Both IE8 and Chrome use the full url including parameters.

We were able to fix this with a custom implementation of Digest authorization. See this answer .

0


a source







All Articles