Bug 26858 - HttpListener's scheme parser is case sensitive
Summary: HttpListener's scheme parser is case sensitive
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 3.12.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Reported: 2015-02-09 07:57 UTC by Valery Dachev
Modified: 2015-03-13 12:43 UTC (History)
2 users (show)

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

A demo program (707 bytes, text/plain)
2015-02-09 07:58 UTC, Valery Dachev

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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Valery Dachev 2015-02-09 07:57:09 UTC
According to RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1) scheme in URL should be case insensitive. However, HttpListener doesn't seem to transform URLs in their canonical form and that leads to broken handling of some (broken) HTTP requests.

The attached example server is sent a request and should produce a response with status code 20 containing the raw URL of the request.

a) if a request is made to "http://localhost:9999/", the response is:
=== snip = snip = snip ===
--> GET Http://localhost:9999/ HTTP/1.0
<-- HTTP/1.1 200 OK
<-- Server: Mono-HTTPAPI/1.0
<-- Date: Mon, 09 Feb 2015 12:38:59 GMT
<-- Connection: close

=== snip = snip = snip ===

b) if a request is made to "Http://localhost:9999/" (notice the scheme case?), the response should be the same as a), but instead:

=== snip = snip = snip ===
--> GET Http://localhost:9999/ HTTP/1.0
<-- HTTP/1.1 400 Bad Request
<-- Content-Type: text/html; charset=utf-8
<-- Server: Mono-HTTPAPI/1.0
<-- Date: Mon, 09 Feb 2015 12:38:45 GMT
<-- Content-Length: 79
<-- Connection: close
<-- <h1>Bad Request (Invalid url:</h1>
=== snip = snip = snip ===

*** NOTE: The behavior of Microsoft's .NET Framework 4.5 is correct. However, NHttp (https://www.nuget.org/packages/NHttp/0.1.6) has just the same bug.
Comment 1 Valery Dachev 2015-02-09 07:58:21 UTC
Created attachment 9706 [details]
A demo program
Comment 2 Valery Dachev 2015-02-11 10:47:03 UTC
I've tested it on Ubuntu - both original 3.2.8 from both the Ubuntu Utopic repository and 3.12.0 from the Mono repository for Debian Wheezy.
Comment 3 Marek Safar 2015-02-18 11:01:39 UTC
I cannot reproduce it with Mono master. I tested the request using HttpClient and I am not certain it does not do url transformation somewhere down to the stack
Comment 4 Valery Dachev 2015-02-26 06:55:11 UTC
HttpClient might tweak the request and lower-case the schema in the URL, and such a test is therefore unreliable. That's why I tested it with a "telnet". And that's why I reopen the bug.
Comment 5 Marek Safar 2015-03-13 12:42:52 UTC
Fixed in master