Having an issue with our service clients (.Net & ajax) after upgrading to 4.0.60 from 4.0.42 where the Expect 100 Continue request is throwing a HTTP 1.1 RFC error “The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF”. Does anyone know what could be the cause with this? I tried to look at the history for CorsFeature but don’t see any changes there why the headers wouldn’t have a CrLf at the end.
I see many “fixes” for this out on StackOverflow and other sites suggesting on the client adding a web.config entry to ignore this, however this won’t work because need to fix this on the ServiceStack side (AppHost or some other change to avoid this) Any ideas are appreciated!
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
The only things we have special in our AppHost that would possibly be affect this are below. Basically it is some code that attempts to handle IE8/9 CORS issues, it was written some time ago and may have been already resolved in newer versions of SS.
// Add CORS support (includes CORS headers in all requests)
Plugins.Add(new CorsFeature(allowedHeaders: "Content-Type,Authorization"));
// always allow OPTIONS verb (for CORS). Doing it here (RawHttpHandlers) eliminates the need to define "OPTIONS" as an allowable verb for every service.
HostContext.RawHttpHandlers.Add(request => request.HttpMethod == "OPTIONS" ? new CorsHandler() : null);
// remove markdown plugin (interferes with text/plain overrides we use for IE8/9)
Plugins.RemoveAll(x => x is MarkdownFormat);
// treat all plain text data as JSON (IE8/IE9 can only send plain text content-type)
this.PreRequestFilters.Add((request, response) =>
{
var aspNetReq = ((ServiceStack.Host.AspNet.AspNetRequest)request);
aspNetReq.HttpRequest.ContentType = aspNetReq.HttpRequest.ContentType.ToLower();
if (string.IsNullOrWhiteSpace(request.Headers["content-type"]) ||
request.Headers["content-type"].ToLower().Contains("text/plain"))
{
aspNetReq.HttpRequest.ContentType = MimeTypes.Json;
}
});