AddHeader() public method

Called during parsing of a IHttpRequest.
If a header is incorrect.
public AddHeader ( string name, string value ) : void
name string Name of the header, should not be url encoded
value string Value of the header, should not be url encoded
return void
Example #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void OnHeaderReceived(object sender, HeaderEventArgs e)
 {
     if (string.Compare(e.Name, "expect", true) == 0 && e.Value.Contains("100-continue"))
     {
         lock (requestsInServiceIDs)
         {
             if (requestsInServiceIDs.Count == 0)
             {
                 Respond("HTTP/1.1", HttpStatusCode.Continue, "Please continue.");
             }
         }
     }
     m_currentRequest.AddHeader(e.Name, e.Value);
 }
Example #2
0
        ///<summary>
        ///Creates a new object that is a copy of the current instance.
        ///</summary>
        ///
        ///<returns>
        ///A new object that is a copy of this instance.
        ///</returns>
        ///<filterpriority>2</filterpriority>
        public object Clone()
        {
            // this method was mainly created for testing.
            // dont use it that much...
            var request = new HttpRequest();

            request.Method = _method;
            if (AcceptTypes != null)
            {
                request.AcceptTypes = new string[AcceptTypes.Length];
                AcceptTypes.CopyTo(request.AcceptTypes, 0);
            }
            request._httpVersion = _httpVersion;
            request._queryString = _queryString;
            request.Uri          = _uri;

            var buffer = new byte[_body.Length];

            _body.Read(buffer, 0, (int)_body.Length);
            request.Body = new MemoryStream();
            request.Body.Write(buffer, 0, buffer.Length);
            request.Body.Seek(0, SeekOrigin.Begin);
            request.Body.Flush();

            request._headers.Clear();
            foreach (string key in _headers)
            {
                string[] values = _headers.GetValues(key);
                if (values != null)
                {
                    foreach (string value in values)
                    {
                        request.AddHeader(key, value);
                    }
                }
            }
            Clear();
            return(request);
        }
Example #3
0
    ///<summary>
    ///Creates a new object that is a copy of the current instance.
    ///</summary>
    ///
    ///<returns>
    ///A new object that is a copy of this instance.
    ///</returns>
    ///<filterpriority>2</filterpriority>
    public object Clone()
    {
      // this method was mainly created for testing.
      // dont use it that much...
      var request = new HttpRequest();
      request.Method = _method;
      if (AcceptTypes != null)
      {
        request.AcceptTypes = new string[AcceptTypes.Length];
        AcceptTypes.CopyTo(request.AcceptTypes, 0);
      }
      request._httpVersion = _httpVersion;
      request._queryString = _queryString;
      request.Uri = _uri;

      var buffer = new byte[_body.Length];
      _body.Read(buffer, 0, (int) _body.Length);
      request.Body = new MemoryStream();
      request.Body.Write(buffer, 0, buffer.Length);
      request.Body.Seek(0, SeekOrigin.Begin);
      request.Body.Flush();

      request._headers.Clear();
      foreach (string key in _headers)
      {
        string[] values = _headers.GetValues(key);
        if (values != null)
          foreach (string value in values)
            request.AddHeader(key, value);
      }
      Clear();
      return request;
    }