Bug 7889 - Incorrect Content-Type header sent when using context.Response.Headers.Add
Summary: Incorrect Content-Type header sent when using context.Response.Headers.Add
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-10-18 01:55 UTC by superfuzzjunk
Modified: 2012-10-25 01:09 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description superfuzzjunk 2012-10-18 01:55:28 UTC
Description of problem: (ASP.NET under Mono on linux)
Using HttpContext context.Response.Headers.Add("Content-Type", "image/jpeg") results in a content type of "text/html" being sent to the client; however, using context.Response.ContentType = "image/jpeg" results in the corrent MIME type being sent to the client. The exact MIME type does not appear to matter, "image/jpeg" just happened to be what I was working with. The HttpContext is obtained via the ProcessRequest method of an IHttpHandler. Other headers such as ETag, Last-Modified, and Content-Length are correctly sent to the client, the only affected header appears to be Content-Type.

Steps to reproduce:
1) Create a simple IHttpHandler class and add a custom content type via context.Response.Header.Add.
2) Request the handler class via a client and examine the Content-Type header (I was using FireFox and FireBug).

Result:
The Content-Type header has the (default?) value of "text/html" instead of the value specified by the header that was added to the handler.

Expected Result:
The Content-Type header sent to the client has the value specified by the header added to the handler.

Environment Information:
Mono JIT compiler version 2.10.6 (tarball Wed Aug 15 11:55:02 UTC 2012)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          debugger softdebug
        LLVM:          supported, not enabled.
        GC:            Included Boehm (with typed GC and Parallel Mark)

OS: openSUSE 12.2 x64
Web Server: Apache 2.2.22
ASP.NET version: 2.0.50727 (as sent by the X-AspNet-Version header, the project file targets .NET 3.5)

Additional Information:
While running this on a Windows 7 x64/IIS7/.NET environment the correct content type is sent, this only happens when the HTTP handler is running under linux/apache/mono.

Work-around:
Specifying the content type via context.ContentType = "image/jpeg" produces the expected result.
Comment 1 Zoltan Varga 2012-10-23 18:47:11 UTC
-> sys.web.
Comment 2 superfuzzjunk 2012-10-25 01:09:28 UTC
Oops, my apologies. Yes, it is a System.Web.HttpContext object.

Note You need to log in before you can comment on or make changes to this bug.