本文整理汇总了C#中IRequestContext.End方法的典型用法代码示例。如果您正苦于以下问题:C# IRequestContext.End方法的具体用法?C# IRequestContext.End怎么用?C# IRequestContext.End使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRequestContext
的用法示例。
在下文中一共展示了IRequestContext.End方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnHandleRequest
//.........这里部分代码省略.........
var enc = response.Encoding;
headerValue = (headerValue ?? string.Empty).ToLower().Trim();
if (headerValue == "")
{
headerValue = StringHelper.AsString(this.GetDefaultContentType(request, response));
}
if (enc != null)
{
// append charset
headerValue += "; charset=" + enc.WebName;
}
}
sendHeader(headerName, headerValue);
}
}
// forced headers
foreach (var entry in forcedHeaders)
{
sendHeader(entry.Key, entry.Value);
}
// update headers
if (updateHeaders)
{
// content length
{
if (!contentLength.HasValue)
{
if (outputStream != null)
{
try
{
if (outputStream.CanSeek)
{
contentLength = outputStream.Length;
}
}
catch
{
// ignore errors
}
}
}
if (contentLength.HasValue)
{
sendHeader(HEADER_CONTENT_LENGTH, contentLength);
}
}
}
// separator between header and body
context.Write(encoder.GetBytes(newLine));
sendOutputStream();
}
finally
{
context.End();
}
};
if (request.IsMethodAllowed)
{
switch (request.KnownMethod)
{
case HttpMethod.HEAD:
unsetOutputStream();
break;
case HttpMethod.OPTIONS:
code = 200;
var supportedMethods = request.SupportedMethods ?? new List<string>();
headers = new Dictionary<string, string>();
headers.Add("Allow",
string.Join(",", supportedMethods.Select(x => (x ?? string.Empty).ToUpper().Trim())
.Where(x => x != string.Empty)
.Distinct()));
unsetOutputStream();
break;
case HttpMethod.TRACE:
unsetOutputStream();
headers = request.Headers;
outputStream = context.GetBodyStream(ref bufferReadSize);
updateHeaders = false;
break;
}
}
sendResponse();
}