Bug 6213 - HTTP request stream does not support seek
Summary: HTTP request stream does not support seek
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: master
Hardware: Other Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-07-20 12:35 UTC by David Straw
Modified: 2012-08-11 00:17 UTC (History)
2 users (show)

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 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 David Straw 2012-07-20 12:35:05 UTC
The read-only stream created for reading HTTP requests returns False for CanSeek. The type I see being used in Mono is System.Net.RequestStream.

This causes numerous problems in ASP.NET Web API, which appears to assume that the request stream supports seek. I also need the ability to seek on this stream in my application.

I'll work on getting more details and creating a test case for this.
Comment 1 David Straw 2012-07-20 13:47:53 UTC
It looks like the inner-most stream in an HttpListener in .NET doesn't support seeking, but at some point in the ASP.NET Web API stack the stream gets wrapped in a buffering stream. This is the part that's not working in mono, so it may be specific to ASP.NET Web API.

I'm still trying to track down the calls that Web API is making from which it expects to receive a buffered stream.
Comment 2 David Straw 2012-07-26 12:38:54 UTC
I tracked down the root cause to the RequestStream class, which was returning -1 instead of 0 for the number of bytes read in EndRead at the end of the stream. I have fixed this in my fork at https://github.com/strawd/mono/commit/2d420541ed6fb18d436be8b83d5b9c9fae9d3263 and have submitted a pull request to mono master.
Comment 3 Gonzalo Paniagua Javier 2012-08-11 00:17:19 UTC
Fixed in master with David's patch. master/aa1c098cb9