[Mono-dev] BUG in System.Web.HttpResponse

Edward C. Eisenbrey nede at aliquant.com
Mon Feb 13 11:04:53 EST 2006


Please bear with me since this is my first post to this list.  If I do
something wrong or forget something, let me know so I can learn.

I've encountered a bug moving an MS .NET Framework v1.1 web application
to Mono.  We use the following call:

Response.AddHeader("Cache-Control", "no-cache, no-store");

Which works fine in MS's Framework.  In Mono, however, it gives an error
saying "CacheControl property only allows `public', `private' or
no-cache, for different uses, use Response.AppendHeader".  First, this
is an incompatibility with MS.  Secondly, Response.AddHeader calls
Response.AppendHeader in Mono, which sets the CacheControl property,
which throws this exception.  So there is a logic loop.  I propose the
following change to the AppendHeader method, starting on line 419:

//
// AppendHeader:
//    Special case for Content-Length, Content-Type and
Transfer-Encoding
//
//
public void AppendHeader (string name, string value)
{
	if (headers_sent)
		throw new HttpException ("headers have been already
sent");
	
	if (String.Compare (name, "content-length", true,
CultureInfo.InvariantCulture) == 0){
		content_length = (long) UInt64.Parse (value);
		use_chunked = false;
		return;
	}

	if (String.Compare (name, "content-type", true,
CultureInfo.InvariantCulture) == 0){
		ContentType = value;
		return;
	}

	if (String.Compare (name, "transfer-encoding", true,
CultureInfo.InvariantCulture) == 0){
		transfer_encoding = value;
		use_chunked = false;
		return;
	}

	headers.Add (new UnknownResponseHeader (name, value));
}

I just removed the "if" checking for a header name of "cache-control".




More information about the Mono-devel-list mailing list