[Mono-dev] ASP.Net HttpResponse.SuppressContent

Arnhoffer Károly karnhoffer at ecron.hu
Tue Jan 24 10:00:42 EST 2006


Hi Gonzalo,

I have seen you inspected the problem under Bugzilla and found it to be not a bug. Well I downloaded the newest sources from svn and installed and SuppressContent still does not work. :-( I may do some mistakes somewhere...

But I still do not understand something in the implementation of HttpResponse (from HttpResponse.cs):

		internal void Flush (bool final_flush)
		{
...
			bool head = ((context != null) && (context.Request.HttpMethod == "HEAD"));
			if (suppress_content || head) {
				if (!headers_sent)
					WriteHeaders (true);
				output_stream.Clear ();
				if (WorkerRequest != null)
					output_stream.Flush (WorkerRequest, true); // ignore final_flush here.
				return;
			}
...
		}

It says write the headers even suppress_content is true. And that seems to be the problem here: my response HTML contains only a header (Content-Type).
That is it:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-2"></HEAD>
<BODY></BODY></HTML>

This header seems to be added by the WriteHeaders method here:

		internal void WriteHeaders (bool final_flush)
		{

...
			//
			// Content-Type
			//
			if (content_type != null){
				string header = content_type;

				if (charset_set || header == "text/plain" || header == "text/html") {
					if (header.IndexOf ("charset=") == -1) {
						if (charset == null || charset == "")
							charset = ContentEncoding.HeaderName;
						header += "; charset=" + charset;
					}
				}
				
				write_headers.Add (new UnknownResponseHeader ("Content-Type", header));
			}

...
			
			//
			// Flush
			//
			if (context != null) {
				HttpApplication app_instance = context.ApplicationInstance;
				if (app_instance != null)
					app_instance.TriggerPreSendRequestHeaders ();
			}
			if (WorkerRequest != null) {
				foreach (BaseResponseHeader header in write_headers){
					header.SendContent (WorkerRequest);
				}
			}
			headers_sent = true;
		}

So what should the problem be here? Why does my server write headers? And why does your not? There is a setting in Web.config:

    <globalization 
		requestEncoding="iso-8859-2" 
		responseEncoding="iso-8859-2" 
	/>

When I comment out the whole globalization setting the header is sent again.

Any ideas what I should do now?

Thanks!

(K)
-----Original Message-----
From: Gonzalo Paniagua Javier [mailto:gonzalo at ximian.com] 
Sent: Friday, January 20, 2006 5:20 PM
To: Arnhoffer Károly
Subject: RE: [Mono-dev] ASP.Net HttpResponse.SuppressContent


On Fri, 2006-01-20 at 11:09 +0100, Arnhoffer Károly wrote:
> Sorry how can I attach a test case? http://www.mono-project.com/Bugs 
> says "Submit a test case, the smaller, the better. You can do this by 
> clicking on the >>Create a new attachment<< link.". But I can not find 
> a link like that.

I've seen that you already figured out how to workaround that :).

If you enter a new bug and you're logged in, you'll see the 'Create a new attachment' link below the 'Description' textbox.

I'll fix that bug in the next few hours.
Thanks.

-Gonzalo





More information about the Mono-devel-list mailing list