3

I have an asp.net mvc application running on IIS 7. The problem I'm having is that depending on client the response may be recived (as seen through fiddler) as "chunked transfer-encoding. What I can't understand is why this only happens to some of my clients (even if two computers is on the same network with the same browser (IE 8) and not everyone, or vice versa?

Could anyone explain this to me?

Sorry for this late update, but the problem turned out to be the result of how the user reached the server. If the user was connected to the local lan through a vpn-connection the proxy would be sidestepped otherwise the proxy would be used. This resulted in two different results.

Vinblad
  • 676
  • 1
  • 7
  • 18
  • Why is this a problem? You seem to be using MSIE8, which handles both chunked and non-chunked responses well. The response, for the end-user, will look the same - after dechunking, both responses will be identical. Do you have some functionality that depends on chunks being present? – Piskvor left the building Nov 19 '09 at 07:42
  • Where not sure if this is the cause of an other problem we have where the clients who get's the chunked response don't get the latest version of some javascript files that published to the webbapplication. And also, Im curious to why this happens. Seem strange that the result from IIS is different under the "same" condititions. – Vinblad Nov 19 '09 at 07:45
  • I had some problems when gzipping and chunking the same response (a bit of an edge case), maybe that could be an issue? – Piskvor left the building Nov 19 '09 at 07:47
  • 2
    Let's be clear here: You're having a problem (outdated files) and you've noticed what is almost certainly an unrelated quirk (Sometimes chunked, sometimes not). You should focus your investigation on the problem, not the quirk. Responses are chunked when they're being dynamically generated and output buffering isn't enabled. If the response has been buffered, or even cached by IIS, there's no reason to use Chunked Encoding, and the server will instead send a content-length header. – EricLaw Nov 19 '09 at 18:52
  • Yes you are probably right, but I found it strange that a response from the server (under the same conditions, as far as I know) is different. I find it easier to locate the real problem if I eliminate such variables. – Vinblad Nov 20 '09 at 09:26

2 Answers2

2

Chunked encoding is enabled on the server side if you prematurely flush the output stream. Do you have any user-agent-specific code might be calling Flush()?

RickNZ
  • 18,448
  • 3
  • 51
  • 66
  • What I can't understand is why the result differs between clients. My co-worker next to me on the same network with the same type of computer does not get the response sent to him (where both using IE 8) in a chunked format, while I do. Both using the same webbsite with the same scripts and same webbpage. If chunked encoding is enbaled on the server, should't it mean all responsed are sent as chunked? – Vinblad Nov 19 '09 at 07:26
  • Are you both using the same version of Fiddler? When using a proxy like Fiddler, it will be the one actually making the request to your web server, not the browser. – RickNZ Nov 19 '09 at 14:50
  • 1
    @RickNZ: While that's true, it's not the "x factor" here. Fiddler doesn't interfere with chunking. – EricLaw Nov 19 '09 at 18:50
  • Hi EricLaw! The difference in the response header is this. When chunked the Header.Miscellaneous.Server: mc (where MC probably is the subdomainname in IIS). When NOT chunked the Header.Miscellaneous.Server: Microsoft-IIS/7.0 That's the only difference I can see (except for previously mentioned). – Vinblad Nov 20 '09 at 08:35
  • @RickNZ: EricLaw is the creator of the excellent Fiddler, so he probably knows what it does or does not ;) Anyway, if you want to minimize the observer effect, try capturing your traffic off the network, e.g. with Wireshark. Although it's a bit harder to use, it is a passive capture, so the traffic is not affected. – Piskvor left the building Nov 20 '09 at 08:48
  • @Piskor: Something is obviously different between the two clients, since the response is different. If the browsers, OS, etc, are the same, then what else could it be? If not Fiddler, perhaps configuration settings? Using WireShark sounds like a great idea. – RickNZ Nov 20 '09 at 09:32
  • @RickNZ: BHOs and browser toolbars, registry settings, ActiveX objects, plugins? – Piskvor left the building Nov 20 '09 at 14:16
  • @Piskvor: sure; all are possibilities. The first question is what's different in the HTTP request headers; hopefully that will lead to why they're different. – RickNZ Nov 21 '09 at 01:42
  • @EricLaw, with fiddler off, chunking works for me, but whenewer I turn it on on my computer, i get the complete response. Can you please direct me to the way to solve this problem? What is causing it? – Vlas Bashynskyi Jul 23 '14 at 09:15
  • @VLAS I don't understand your question. Taking a guess: Have you depressed the `Stream` or `Decode` button on the toolbar in Fiddler? – EricLaw Jul 23 '14 at 11:40
  • @EricLaw, thank you very much, that was the `Stream` button. I was testing an application that would send text in intervals (using chunked encoding ), but text would be displayed only when completely arrived. – Vlas Bashynskyi Jul 23 '14 at 12:52
1

RFC 2616 says:

All HTTP/1.1 applications MUST be able to receive and decode the "chunked" transfer-coding

Transfer-Encoding: chunked is defined for HTTP/1.1. Are some of your clients using HTTP/1.0 or even (shudder) 0.9? In that case, the server must not use transfer-encoding, as it's not a part of the protocol.

Although most modern clients understand HTTP/1.1, most have an option to downgrade to 1.0 when using a proxy (for historical reasons - some older proxies had buggy 1.1 implementations). So, although the browser may understand 1.1, it can request 1.0 if so instructed.

Example: MSIE 6+ has this in the Internet Options dialog - tab Advanced - HTTP 1.1 settings - checkboxes "Use HTTP 1.1" and "Use HTTP 1.1 through proxy connections".

Also, chunked encoding is not activated for all responses - usually the server switches it on when Content-Length is not set, or when the output buffer is flushed.

Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
  • Thanx for the reply. Whats strange is that even with the same network and same version of IE (version 8). The problem occurs between different computers. – Vinblad Nov 19 '09 at 07:34
  • Yes, I understand that. What I'm saying is that two computers with an identical version of Win/IE can exhibit different behavior when those settings are enabled on one and disabled on another. – Piskvor left the building Nov 19 '09 at 07:36
  • Thanx for the tip, we've verified that the settings are the same but the problem remains. – Vinblad Nov 19 '09 at 07:38