예제 #1
0
        private void GetUnknownHeadersHelper(IDictionary <string, StringValues> unknownHeaders, long fixup, HttpApiTypes.HTTP_REQUEST *request)
        {
            int index;

            // unknown headers
            if (request->Headers.UnknownHeaderCount != 0)
            {
                var pUnknownHeader = (HttpApiTypes.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)
                    {
                        var    headerName = HeaderEncoding.GetString(pUnknownHeader->pName + fixup, pUnknownHeader->NameLength);
                        string headerValue;
                        if (pUnknownHeader->pRawValue != null && pUnknownHeader->RawValueLength > 0)
                        {
                            headerValue = HeaderEncoding.GetString(pUnknownHeader->pRawValue + fixup, pUnknownHeader->RawValueLength);
                        }
                        else
                        {
                            headerValue = string.Empty;
                        }
                        // Note that Http.Sys currently collapses all headers of the same name to a single coma separated string,
                        // so we can just call Set.
                        unknownHeaders[headerName] = headerValue;
                    }
                    pUnknownHeader++;
                }
            }
        }
예제 #2
0
        // These methods require the HTTP_REQUEST to still be pinned in its original location.

        internal string GetVerb()
        {
            var verb = NativeRequest->Verb;

            if (verb > HttpApiTypes.HTTP_VERB.HttpVerbUnknown && verb < HttpApiTypes.HTTP_VERB.HttpVerbMaximum)
            {
                return(HttpApiTypes.HttpVerbs[(int)verb]);
            }
            else if (verb == HttpApiTypes.HTTP_VERB.HttpVerbUnknown && NativeRequest->pUnknownVerb != null)
            {
                return(HeaderEncoding.GetString(NativeRequest->pUnknownVerb, NativeRequest->UnknownVerbLength));
            }

            return(null);
        }
예제 #3
0
        private string GetKnowHeaderHelper(HttpSysRequestHeader header, long fixup, HttpApiTypes.HTTP_REQUEST *request)
        {
            int    headerIndex = (int)header;
            string value       = null;

            HttpApiTypes.HTTP_KNOWN_HEADER *pKnownHeader = (&request->Headers.KnownHeaders) + headerIndex;
            // For known headers, when header value is empty, RawValueLength will be 0 and
            // pRawValue will point to empty string ("\0")
            if (pKnownHeader->RawValueLength > 0)
            {
                value = HeaderEncoding.GetString(pKnownHeader->pRawValue + fixup, pKnownHeader->RawValueLength);
            }

            return(value);
        }