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)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 7889 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

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.