本文整理汇总了C#中System.Net.WebHeaderCollection.AddInternal方法的典型用法代码示例。如果您正苦于以下问题:C# WebHeaderCollection.AddInternal方法的具体用法?C# WebHeaderCollection.AddInternal怎么用?C# WebHeaderCollection.AddInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.WebHeaderCollection
的用法示例。
在下文中一共展示了WebHeaderCollection.AddInternal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileWebResponse
// constructors
internal FileWebResponse(FileWebRequest request, Uri uri, FileAccess access, bool asyncHint) {
GlobalLog.Enter("FileWebResponse::FileWebResponse", "uri="+uri+", access="+access+", asyncHint="+asyncHint);
try {
m_fileAccess = access;
if (access == FileAccess.Write) {
m_stream = Stream.Null;
} else {
//
// apparently, specifying async when the stream will be read
// synchronously, or vice versa, can lead to a 10x perf hit.
// While we don't know how the app will read the stream, we
// use the hint from whether the app called BeginGetResponse
// or GetResponse to supply the async flag to the stream ctor
//
m_stream = new FileWebStream(request,
uri.LocalPath,
FileMode.Open,
FileAccess.Read,
FileShare.Read,
DefaultFileStreamBufferSize,
asyncHint
);
m_contentLength = m_stream.Length;
}
m_headers = new WebHeaderCollection(WebHeaderCollectionType.FileWebResponse);
m_headers.AddInternal(HttpKnownHeaderNames.ContentLength, m_contentLength.ToString(NumberFormatInfo.InvariantInfo));
m_headers.AddInternal(HttpKnownHeaderNames.ContentType, DefaultFileContentType);
m_uri = uri;
} catch (Exception e) {
Exception ex = new WebException(e.Message, e, WebExceptionStatus.ConnectFailure, null);
GlobalLog.LeaveException("FileWebResponse::FileWebResponse", ex);
throw ex;
}
catch {
Exception ex = new WebException(string.Empty, new Exception(SR.GetString(SR.net_nonClsCompliantException)), WebExceptionStatus.ConnectFailure, null);
GlobalLog.LeaveException("FileWebResponse::FileWebResponse", ex);
throw ex;
}
GlobalLog.Leave("FileWebResponse::FileWebResponse");
}
示例2: GetHeaders
// Server API
internal static WebHeaderCollection GetHeaders(byte[] memoryBlob, IntPtr originalAddress)
{
GlobalLog.Enter("HttpApi::GetHeaders()");
// Return value.
WebHeaderCollection headerCollection = new WebHeaderCollection(WebHeaderCollectionType.HttpListenerRequest);
fixed (byte* pMemoryBlob = memoryBlob)
{
HTTP_REQUEST* request = (HTTP_REQUEST*) pMemoryBlob;
long fixup = pMemoryBlob - (byte*) originalAddress;
int index;
// unknown headers
if (request->Headers.UnknownHeaderCount != 0)
{
HTTP_UNKNOWN_HEADER* pUnknownHeader = (HTTP_UNKNOWN_HEADER*) (fixup + (byte*) request->Headers.pUnknownHeaders);
for (index = 0; index < request->Headers.UnknownHeaderCount; index++)
{
// For unknown headers, when header value is empty, RawValueLength will be 0 and
// pRawValue will be null.
if (pUnknownHeader->pName != null && pUnknownHeader->NameLength > 0)
{
string headerName = new string(pUnknownHeader->pName + fixup, 0, pUnknownHeader->NameLength);
string headerValue;
if (pUnknownHeader->pRawValue != null && pUnknownHeader->RawValueLength > 0) {
headerValue = new string(pUnknownHeader->pRawValue + fixup, 0, pUnknownHeader->RawValueLength);
}
else {
headerValue = string.Empty;
}
headerCollection.AddInternal(headerName, headerValue);
}
pUnknownHeader++;
}
}
// known headers
HTTP_KNOWN_HEADER* pKnownHeader = &request->Headers.KnownHeaders;
for (index = 0; index < HttpHeaderRequestMaximum; index++)
{
// For known headers, when header value is empty, RawValueLength will be 0 and
// pRawValue will point to empty string ("\0")
if (pKnownHeader->pRawValue != null)
{
string headerValue = new string(pKnownHeader->pRawValue + fixup, 0, pKnownHeader->RawValueLength);
headerCollection.AddInternal(HTTP_REQUEST_HEADER_ID.ToString(index), headerValue);
}
pKnownHeader++;
}
}
GlobalLog.Leave("HttpApi::GetHeaders()");
return headerCollection;
}
示例3: GetHeaders
internal static unsafe WebHeaderCollection GetHeaders(byte[] memoryBlob, IntPtr originalAddress)
{
WebHeaderCollection headers = new WebHeaderCollection(WebHeaderCollectionType.HttpListenerRequest);
fixed (byte* numRef = memoryBlob)
{
int num2;
HTTP_REQUEST* http_requestPtr = (HTTP_REQUEST*) numRef;
long num = (long) ((numRef - ((void*) originalAddress)) / 1);
if (http_requestPtr->Headers.UnknownHeaderCount != 0)
{
HTTP_UNKNOWN_HEADER* http_unknown_headerPtr = ((HTTP_UNKNOWN_HEADER*) num) + http_requestPtr->Headers.pUnknownHeaders;
for (num2 = 0; num2 < http_requestPtr->Headers.UnknownHeaderCount; num2++)
{
if ((http_unknown_headerPtr->pName != null) && (http_unknown_headerPtr->NameLength > 0))
{
string str2;
string name = new string(http_unknown_headerPtr->pName + ((sbyte*) num), 0, http_unknown_headerPtr->NameLength);
if ((http_unknown_headerPtr->pRawValue != null) && (http_unknown_headerPtr->RawValueLength > 0))
{
str2 = new string(http_unknown_headerPtr->pRawValue + ((sbyte*) num), 0, http_unknown_headerPtr->RawValueLength);
}
else
{
str2 = string.Empty;
}
headers.AddInternal(name, str2);
}
http_unknown_headerPtr++;
}
}
HTTP_KNOWN_HEADER* http_known_headerPtr = &http_requestPtr->Headers.KnownHeaders;
for (num2 = 0; num2 < 0x29; num2++)
{
if (http_known_headerPtr->pRawValue != null)
{
string str3 = new string(http_known_headerPtr->pRawValue + ((sbyte*) num), 0, http_known_headerPtr->RawValueLength);
headers.AddInternal(HTTP_REQUEST_HEADER_ID.ToString(num2), str3);
}
http_known_headerPtr++;
}
}
return headers;
}