bool _bBuffering;
bool _bHeadersSent;
bool _bFlushing;
+ bool filtered;
long _lContentLength;
int _iStatusCode;
Flush (true);
}
- internal void DoFilter ()
+ internal void DoFilter (bool really)
{
- if (null != _Writer)
+ if (really && null != _Writer)
_Writer.FilterData (true);
+
+ filtered = true;
}
[MonoTODO("We need to add cache headers also")]
if (_Cookies != null) {
int length = _Cookies.Count;
- for (int i = 0; i < length; i++)
+ for (int i = 0; i < length; i++) {
oHeaders.Add (_Cookies.Get (i).GetCookieHeader ());
+ }
}
return oHeaders;
throw new NotImplementedException ();
}
- [MonoTODO()]
public string ApplyAppPathModifier (string virtualPath)
{
- throw new NotImplementedException ();
+ if (virtualPath == null)
+ return null;
+
+ if (virtualPath == "")
+ return _Context.Request.RootVirtualDir;
+
+ if (UrlUtils.IsRelativeUrl (virtualPath)) {
+ virtualPath = UrlUtils.Combine (_Context.Request.RootVirtualDir, virtualPath);
+ } else if (UrlUtils.IsRooted (virtualPath)) {
+ virtualPath = UrlUtils.Reduce (virtualPath);
+ }
+
+ return virtualPath;
}
public bool Buffer
}
}
- public HttpRequest Request
+ HttpRequest Request
{
get {
if (_Context == null)
Flush (true);
}
- [MonoTODO("Check timeout and if we can cancel the thread...")]
public void End ()
{
- if (!_bEnded) {
- Flush ();
- _WorkerRequest.CloseConnection ();
- _bEnded = true;
- }
+ if (_bEnded)
+ return;
+
+ Flush ();
+ _bEnded = true;
+ _Context.ApplicationInstance.CompleteRequest ();
}
public void Flush ()
}
try {
- long length;
- if (!_bHeadersSent && !_bSuppressHeaders && !_bClientDisconnected) {
+ if (_bClientDisconnected)
+ return;
+
+ long length = _Writer.BufferSize;
+ if (!_bHeadersSent && !_bSuppressHeaders) {
if (bFinish) {
- length = _Writer.BufferSize;
if (length == 0 && _lContentLength == 0)
_sContentType = null;
length = _Writer.BufferSize;
if (length != 0)
_WorkerRequest.SendCalculatedContentLength ((int) length);
- } else if (_lContentLength == 0 && _iStatusCode == 200 &&
+ } else {
+ if (_lContentLength == 0 && _iStatusCode == 200 &&
_sTransferEncoding == null) {
- // Check we are going todo chunked encoding
- string sProto = Request.ServerVariables ["SERVER_PROTOCOL"];
-
- if (sProto != null && sProto == "HTTP/1.1") {
- AppendHeader (
- HttpWorkerRequest.HeaderTransferEncoding,
- "chunked");
- } else {
- // Just in case, the old browsers sends a HTTP/1.0
- // request with Connection: Keep-Alive
- AppendHeader (
- HttpWorkerRequest.HeaderConnection,
- "Close");
+ // Check we are going todo chunked encoding
+ string sProto = Request.ServerVariables ["SERVER_PROTOCOL"];
+ sProto = "HTTP/1.0"; // Remove this line when we support properly
+ // chunked content
+
+ if (sProto != null && sProto == "HTTP/1.1") {
+ AppendHeader (
+ HttpWorkerRequest.HeaderTransferEncoding,
+ "chunked");
+ } else {
+ // Just in case, the old browsers send a HTTP/1.0
+ // request with Connection: Keep-Alive
+ AppendHeader (
+ HttpWorkerRequest.HeaderConnection,
+ "Close");
+ }
}
+ length = _Writer.BufferSize;
SendHeaders ();
}
}
+ if (!filtered) {
+ _Writer.FilterData (false);
+ length = _Writer.BufferSize;
+ }
+
+ if (length == 0) {
+ _WorkerRequest.FlushResponse (bFinish);
+ if (!bFinish)
+ _Writer.Clear ();
+ return;
+ }
+
if (!_bSuppressContent && Request.HttpMethod == "HEAD")
_bSuppressContent = true;
Clear ();
+ url = ApplyAppPathModifier (url);
StatusCode = 302;
AppendHeader (HttpWorkerRequest.HeaderLocation, url);