string Fill(HttpWorkerRequest wr, bool standard)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < HttpWorkerRequest.RequestHeaderMaximum; i++)
            {
                string val = wr.GetKnownRequestHeader(i);
                if (val == null || val == "")
                {
                    continue;
                }
                string key = HttpWorkerRequest.GetKnownRequestHeaderName(i);
                AppendKeyValue(sb, key, val, standard);
            }
            string [][] other = wr.GetUnknownRequestHeaders();
            if (other == null)
            {
                return(sb.ToString());
            }

            for (int i = other.Length; i > 0;)
            {
                i--;
                AppendKeyValue(sb, other [i][0], other [i][1], standard);
            }

            return(sb.ToString());
        }
        protected override void InsertInfo()
        {
            HttpWorkerRequest worker_request = _request.WorkerRequest;

            if (null != worker_request)
            {
                for (int i = 0; i < HttpWorkerRequest.RequestHeaderMaximum; i++)
                {
                    string hval = worker_request.GetKnownRequestHeader(i);

                    if (hval == null || hval == "")
                    {
                        continue;
                    }

                    Add(HttpWorkerRequest.GetKnownRequestHeaderName(i), hval);
                }

                string [] [] unknown = worker_request.GetUnknownRequestHeaders();
                if (unknown != null && unknown.GetUpperBound(0) != -1)
                {
                    int top = unknown.GetUpperBound(0) + 1;

                    for (int i = 0; i < top; i++)
                    {
                        // should check if unknown [i] is not null, but MS does not.

                        Add(unknown [i] [0], unknown [i] [1]);
                    }
                }
                Protect();
            }
        }
        void AddHeaderVariables(HttpWorkerRequest wr)
        {
            string hname;
            string hvalue;

            // Add all known headers
            for (int i = 0; i < HttpWorkerRequest.RequestHeaderMaximum; i++)
            {
                hvalue = wr.GetKnownRequestHeader(i);
                if (null != hvalue && hvalue.Length > 0)
                {
                    hname = HttpWorkerRequest.GetKnownRequestHeaderName(i);
                    if (null != hname && hname.Length > 0)
                    {
                        Add("HTTP_" + hname.ToUpper(Helpers.InvariantCulture).Replace('-', '_'), hvalue);
                    }
                }
            }

            // Get all other headers
            string [][] unknown = wr.GetUnknownRequestHeaders();
            if (null != unknown)
            {
                for (int i = 0; i < unknown.Length; i++)
                {
                    hname = unknown [i][0];
                    if (hname == null)
                    {
                        continue;
                    }
                    hvalue = unknown [i][1];
                    Add("HTTP_" + hname.ToUpper(Helpers.InvariantCulture).Replace('-', '_'), hvalue);
                }
            }
        }
Example #4
0
 private void SynchronizeHeader(string name, string value)
 {
     if (StringUtil.StringStartsWith(name, "HTTP_"))
     {
         string header = name.Substring("HTTP_".Length).Replace('_', '-');
         int    knownRequestHeaderIndex = HttpWorkerRequest.GetKnownRequestHeaderIndex(header);
         if (knownRequestHeaderIndex > -1)
         {
             header = HttpWorkerRequest.GetKnownRequestHeaderName(knownRequestHeaderIndex);
         }
         HttpHeaderCollection headers = this._request.Headers as HttpHeaderCollection;
         if (headers != null)
         {
             headers.SynchronizeHeader(header, value);
         }
     }
 }
        private void SynchronizeHeader(String name, String value)
        {
            if (StringUtil.StringStartsWith(name, "HTTP_"))
            {
                // update managed copy of header
                string headerName = name.Substring("HTTP_".Length);
                headerName = headerName.Replace('_', '-');
                int knownIndex = HttpWorkerRequest.GetKnownRequestHeaderIndex(headerName);
                if (knownIndex > -1)
                {
                    headerName = HttpWorkerRequest.GetKnownRequestHeaderName(knownIndex);
                }

                HttpHeaderCollection headers = _request.Headers as HttpHeaderCollection;
                if (headers != null)
                {
                    headers.SynchronizeHeader(headerName, value);
                }
            }
        }