HTTP:DIGEST认证的请求和响应报文

以下是HTTP DIGEST认证的请求和响应报文的例子,供以后参考。

IE

----first request:

GET /boe/checkedServlet HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, */*
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.30729)
Accept-Encoding: gzip, deflate
Host: 127.0.0.1:8000
Connection: Keep-Alive

----first response:

HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 08:00:00 CST
WWW-Authenticate: Digest realm="MyUserRegistry", qop="auth", nonce="75aa99a687ee7f0257d74d18d79482a5", opaque="b5dbd577b5f27cbed5528cdd36fa013a"
Content-Type: text/html;charset=utf-8
Content-Length: 954
Date: Mon, 30 May 2011 12:01:31 GMT

Apache Tomcat/6.0.29 - Error report

HTTP Status 401 -


type Status report

message

description This request requires HTTP authentication ().


Apache Tomcat/6.0.29

HTTP/1.1 200 OK

/
----second request with userName=admin, password=1234:

GET /boe/checkedServlet HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, */*
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.30729)
Accept-Encoding: gzip, deflate
Host: 127.0.0.1:8000
Connection: Keep-Alive
Authorization: Digest username="admin",realm="MyUserRegistry",nonce="75aa99a687ee7f0257d74d18d79482a5",uri="/boe/checkedServlet",cnonce="c7610c2c78d9d095cbe02ac569c5940a",nc=00000001,response="cc1ece8a10aae565a78140399c2fe706",qop="auth",opaque="b5dbd577b5f27cbed5528cdd36fa013a"

----second response:

Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 08:00:00 CST
Content-Length: 0
Date: Mon, 30 May 2011 12:01:47 GMT

Firefox

----first request:

GET /boe/checkedServlet HTTP/1.1
Host: 127.0.0.1:8000
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; zh-CN; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive

----first response:

HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 08:00:00 CST
WWW-Authenticate: Digest realm="MyUserRegistry", qop="auth", nonce="41b7da876d83d2deddcf745916687dd6", opaque="695943daf44100c597fb82a1dde4cf48"
Content-Type: text/html;charset=utf-8
Content-Length: 954
Date: Mon, 30 May 2011 12:07:07 GMT

Apache Tomcat/6.0.29 - Error report

HTTP Status 401 -


type Status report

message

description This request requires HTTP authentication ().


Apache Tomcat/6.0.29

/
----second request with userName=admin, password=1234:

GET /boe/checkedServlet HTTP/1.1
Host: 127.0.0.1:8000
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; zh-CN; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Authorization: Digest username="admin", realm="MyUserRegistry", nonce="41b7da876d83d2deddcf745916687dd6", uri="/boe/checkedServlet", response="833a4cb6b8f6b9ec418239df72e4aa54", opaque="695943daf44100c597fb82a1dde4cf48", qop=auth, nc=00000001, cnonce="082c875dcb2ca740"

----second response:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 08:00:00 CST
Content-Length: 0
Date: Mon, 30 May 2011 12:07:35 GMT

你可能感兴趣的:(HTTP)