ProxyService can't handle the missing content-length headers from core

I’ve run into an issue with ProxyFeature, because the Core (1.0.43) version doesn’t return Content-Length.

For example, if you go to your core demo, http://imgur.netcore.io/, the headers are:

HTTP/1.1 200 OK
Server: nginx/1.11.3
Date: Wed, 05 Jul 2017 20:23:06 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Last-Modified: Sat, 06 May 2017 09:03:36 GMT
Vary: Accept
X-Powered-By: ServiceStack/1.041 NETStandard/.NET

On the 4.5 demo, http://imgur.servicestack.net/, they are:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html
Last-Modified: Thu, 30 Jun 2016 18:28:20 GMT
Vary: Accept
Server: Microsoft-IIS/8.5
X-Powered-By: ServiceStack/4.50 Win32NT/.NET
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 05 Jul 2017 20:22:52 GMT
Content-Length: 3798

Content-length is missing in the core one.

This causes a problem in ProxyService because in this line

it passes the value to the underlying NetCoreResponse, but it’s zero (or -1), which causes an exception.

So, should there be content-length being returned? And/or should ProxyService handle zero or missing content lengths?

Now I see the core version is using “Transfer-Encoding: chunked” so won’t have the length. So just a problem with ProxyService then.

Yeah .NET Core emits chunked encoding so it doesn’t have to know the length, I’ve changed it to skip setting -1 Content-Length’s in this commit. This change is available from v4.5.13 that’s now available on MyGet.