Closed dr4cul4 closed 11 years ago
hmmm. I must have screwed something up with my later fixes. For this I've tried quite extensivly in the past. HTTP/1.1 (reusing the connection) is the prefered way to do it since it speeds up the handling
I have a clue... header parser is messed up. First of all header names are weird for example doing second request I post to "http://127.0.0.1:8283/?module=task&option=list&session=a805183b-af0e-41d5-bf0e-d6e45e3e5be5" But http message has "http://127.0.0.1:8283/?resource=js/bundle.js", Which is last js in my html file.
First Header Name: "GET /?module=task&option=list&session=a805183b-af0e-41d5-bf0e-d6e45e3e5be5 HTTP/1.1 Host" First Header Value: "127.0.0.1:8283"
Those values are strange.
Now I also find something curious. If I have many resources on a page I only get the last one to output (not at first request... at first request i get all things but cutoff)
The problem is most likely that Reset()
doesn't set the _parserMethod
to FirstLine
I'll test this at home. What about stream cutoff? I thinking it has something to do with async handling.
It's probably related. The HeaderParser should take care of headers and leave the body bytes intact. But since the header parsing gets out of sync it will probably effect the body handling too.
If it desn't work I'll post sample project reproducing the problem.
I modified reset method like this and use it inside HeaderDecoder with parameter set to true:
public void Reset(bool first = false)
{
_headerName.Clear();
_headerValue.Clear();
if (first)
_parserMethod = FirstLine;
else
_parserMethod = Name_StripWhiteSpacesBefore;
}
This solved initial problem.
Now my only concern is keep alive set to false. Connection should be closed after data is send. Currently this happens in the middle of the transfer.
I've discovered one more thing.
When page redirects itself it tends to hang one socket... random one. (usually second, but that's not a rule). I'm trying to figure that out. Only thing I can tell now it's that socket is open and listening and browser is reading from it. Browser claims that it send request but there is no data in the web server. When I his stop in browser sockets finishes read with zero bytes. I happens on all browsers.
Also browsing using links and ajax requests works well. At least after hour of clicking.
should work with the next commit
There is a problem with streams and pipelines.
They seam to work on small amount of data, but when you try to use images or something larger output get's mess up. (html is mixed with images and css/js). As it turns out it's related to using same connection by browsers and reading output at the same time.
Also when you switch to keep alive false in response you get more errors (Close message not supported, easy fix), after that i got null reference (socket was null ServerClientContext.cs:218), those two fixes solves my problem partially... now the response is cutoff and I get half of an image, part of js and css. If I find a fix I will post it here. I will also try to solve connection sharing problem.