Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Content-length with 401 response. |
|
Author |
|
pradeepkhopade
Joined: 14 Dec 2007 Posts: 1 Location: Pune
|
Posted: Fri 14 Dec '07 12:13 Post subject: Content-length with 401 response. |
|
|
Hi ,
We have implemented a filter on Apache web server to force the basic authentication for all the resources in the doc root folder.
As per the RFC, we need to return 401 response to any request for a file in doc root folder.
Currently we are returning WWW-Authenticate as a mandatory field and some other optional fields.
We are not sure about the content-length field. We are not returning any contents with 401 response.
1) Can we skip the content-length field?
2) Is it mandatory to return content-length field with 401 responses?
Here is the current header trace with our filter.
GET /basic/testpage.html HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
If-Modified-Since: Thu, 13 Dec 2007 08:21:36 GMT
If-None-Match: "15052-61-a26c4bb7"
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 2.0.50727; InfoPath.1)
Host: ps4480
Connection: Keep-Alive
HTTP/1.1 401 Authorization Required
Date: Thu, 13 Dec 2007 11:27:22 GMT
Server: Apache/2.2.6 (Win32)
WWW-Authenticate: Basic realm="By Invitation Only apache_2.2.6-win32."
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
Thanks,
Pradeep. |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Fri 14 Dec '07 15:05 Post subject: |
|
|
If you are returning a Content-Type header (...it appears that you are...) you should return a Content-length header - even if the length is zero.
For browser compatibility it is better to return some actual content, for example: Code: | <HTML>
<HEAD>
<TITLE>Error</TITLE>
</HEAD>
<BODY>
<H1>401 Unauthorised.</H1>
</BODY>
</HTML> |
What you are trying to do doesn't make much sense. See Nick Kew's answer to your post of the same question in the Apache users list.
-tom-
p.s. It is better to ask questions like this in one forum at a time, rather than cross-post it to several different lists and forums.
-t- |
|
Back to top |
|
|
|
|
|
|