.

HTTP 401 << AnyOne with HTTP ???

<<

teamer

Newbie
Newbie

Posts: 9

Joined: Thu Jun 19, 2008 11:11 am

Post Sat Jun 28, 2008 12:45 pm

HTTP 401 << AnyOne with HTTP ???

hi friends ,i have some problems with the HTTP protocol , scually am not very familiar with HTTP , but i developed a software which has an option of retrieving webpage source code , but some pages are 401 forbidden , i tried to see the data that IE sends to the server when i input a username and password , acually i found that it just sends a normal GET request without any existance of a username or a password !!! can any one help me with this ? my question is how can i send a username and password to a 401 forbidden page ??? , thank you .
<<

shakuni

Jr. Member
Jr. Member

Posts: 80

Joined: Sun Nov 04, 2007 2:24 pm

Post Sat Jun 28, 2008 4:19 pm

Re: HTTP 401 << AnyOne with HTTP ???

my question is how can i send a username and password to a 401 forbidden page

This question should be restated as
How should I send a username and password to a web resource so that I do not get 401.
Actually the language of question shows that you have very superficial understanding of HTTP protocol. So go read rfc 2616 first, especially status codes that are described here- http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
There is no rule, law or tradition that apply universally... including this one.
<<

jimbob

Post Mon Jun 30, 2008 1:47 pm

Re: HTTP 401 << AnyOne with HTTP ???

Usually what is being asked for it HTTP basic authentication. Your program will need to sent an Authorization: HTTP header, assuming you know the username and password. Take a look at the example on the Wikipedia page.

http://en.wikipedia.org/wiki/Basic_acce ... entication

Regards,
Jimbob
<<

teamer

Newbie
Newbie

Posts: 9

Joined: Thu Jun 19, 2008 11:11 am

Post Fri Jul 04, 2008 3:08 am

Re: HTTP 401 << AnyOne with HTTP ???

shakuni wrote:How should I send a username and password to a web resource so that I do not get 401.


hahaha thanks shakuni , acually am very bad in english , second how you will know if that web resource would send you a 401 page or a normal 200 page if you didn't send the normal GET headers first !.

but really thank you , and thank you jimbob too , that wiki was very usefull also , they should merge the 2 sources together somehow .

Thanks
<<

jimbob

Post Fri Jul 04, 2008 8:56 am

Re: HTTP 401 << AnyOne with HTTP ???

[quote author=teamer link=topic=2641.msg12197#msg12197
how you will know if that web resource would send you a 401 page or a normal 200 page if you didn't send the normal GET headers first !.
[/quote]
What happens is you send the normal GET request and the web servers sends back a 401 response. In the response headers there is information about the authenication required to access the page. If I access my home ADSL router for example I get offered Basic and Digest authentication for the realm SpeedTouch.

  Code:
HTTP/1.x 401 Unauthorized
Content-Length: 139
WWW-Authenticate: Digest realm="SpeedTouch", nonce="0732JT3ED:00-14-7F-F7-06-1F:480233:22601", qop="auth"
WWW-Authenticate: Basic realm="SpeedTouch"


This is how your web browser knows to prompt you for a username and password. When your browser receives the WWW-Authenticate header it prompts you for a username and password which it then sends along with the next request.

Jimbob

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron
.
Powered by phpBB® Forum Software © phpBB Group.
Designed by ST Software