Matt
Matt

Reputation: 1704

What piece of configuration controls "HttpBufferlessInputStream.DisableMaxRequestLength"

Working in ASP.NET, I've got an api call to which I want to be able to stream an arbitrarily large payload. I'm running into issues with maximum request length. Digging in a bit, I see this stack:

at System.Web.HttpBufferlessInputStream.ValidateRequestEntityLength()
at System.Web.HttpBufferlessInputStream.EndRead(IAsyncResult asyncResult)
at System.Net.Http.StreamToStreamCopy.StartRead()

Looking at the source for ValidateRequestEntityLength shows the following code:

private void ValidateRequestEntityLength() {
    if (!_disableMaxRequestLength && Length > _maxRequestLength) {
        if ( !(_context.WorkerRequest is IIS7WorkerRequest) ) {
            _context.Response.CloseConnectionAfterError();
        }
        throw new HttpException(SR.GetString(SR.Max_request_length_exceeded), null, WebEventCodes.RuntimeErrorPostTooLarge);
    }
}

where _disableMaxRequestLength is a boolean passed into the constructor for this class. I do not see this class being constructed anywhere in the stack I have available, so I am wondering:

I've looked at the web.config in the Application Pool serving these requests, and I don't see any settings related to "request" or "length" that seem to be in play.

Where else do I look? What other information is relevant to answering this question?

Upvotes: 2

Views: 270

Answers (1)

pinkfloydx33
pinkfloydx33

Reputation: 12789

If you search instead on referencesource.microsoft.com, you can click method names in the source and all callsites will be displayed in the list on the left. From there you can navigate through, backwards, to see how it is called. I use this method a lot when I want to understand the source code. Github source is great too, but the ability to navigate methods, classes and even variables just by clicking their names is second to none.

More specifically, it's an optional parameter, as can be seen here, that defaults to false.

It is called from three places, one of which passes the parameter explicitly as true and traces to here where there are several lines of comments regarding the Request.ReadEntityBodyMode and buffered/bufferless/classic mode. It's also passed through the abstraction of HttpRequestWrapper

Upvotes: 1

Related Questions