title: HttpWebRequest: post method using "useUnsafeHeaderParsing = true"
body: <p>I'm trying to connect to a third party website, and then get the source code.
  <br> It worked well for me, and after some time I tried sign in again and then i got an error message:
  <br> "<strong>{" The server committed a protocol violation. Section = ResponseStatusLine "}</strong>.
  <br> After quick search on google i found out that i sholud to add to  "app.config" the following entry: <code>&lt;httpWebRequest useUnsafeHeaderParsing = true/&gt;</code>
  <br>After that it worked fine. But, I get the source code as a guset, and not as "connected User".</p>
  
  <p>I tried another site that does not require "UseUnsafeHeaderParsing = true" <br> and it worked well.
  It looks like "UseUnsafeHeaderParsing = true" disruptive cookies?</p>
  
  <p>*Sorry for my english, this is not my native language.</p>
  
  <p>this is my code:</p>
  
  <pre><code>Private siteCookies As New Net.CookieContainer()
  
      Function siteRequest(url As String, ByVal Method As String, Optional ByVal data As String = Nothing) As String
          Static soucrecode As String = Nothing
          Const UserAgent As String = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
          Try
  
              Dim Request As Net.HttpWebRequest = Net.WebRequest.Create(url)
              Request.Accept = "*/*"
              Request.Timeout = 10000
              Request.Method = Method
              Request.UserAgent = UserAgent
              Request.AllowAutoRedirect = True
              Request.CookieContainer = siteCookies
              If Request.Method = "POST" AndAlso data IsNot Nothing Then
                  Dim postBytes() As Byte = New UTF8Encoding().GetBytes(data)
                  Request.ContentType = "application/x-www-form-urlencoded"
                  Request.ContentLength = postBytes.Length
                  Request.GetRequestStream().Write(postBytes, 0, postBytes.Length)
              End If
  
              Dim Response As Net.HttpWebResponse = Request.GetResponse()
              soucrecode = New IO.StreamReader(Response.GetResponseStream).ReadToEnd()
              Response.Close()
          Catch e As Exception
           Console.WriteLine(e.Message)
  
          End Try
          Return soucrecode
      End Function
  </code></pre>
  
  <p>using:</p>
  
  <pre><code>txtLoginSoucre.Text = siteRequest("http://www.SomeSite.com/login.php?do=login", "Post", "username=myUser&amp;password=MyPass") ' Login to site
  txtSoucre.Text siteRequest("http:  //www.SomeSite.com", "Get") 'Grab soucrecode
  </code></pre>