Click here for a larger image.
Environment: VS7 C# .NET
I wrote this application to see what the HttpWebRequest and HttpWebResponse classes did. I am not a Web programmer and I’m not that familiar with HTTP or HTML, so I wanted to see what these function do. I’m sure someone else who has a more intimate knowledge of these protocols could do a lot more. I was unsure of what I was seeing, which is why I wrote WebPageGet.
private void GetButtonClick(object sender, System.EventArgs e) { HttpWebRequest httpReq; HttpWebResponse httpResp; Stream httpStream; m_results.Text = ""; MessageBeep(100); try { ASCIIEncoding ASCII = new ASCIIEncoding(); byte[] buf = new byte[ 128000 ]; m_header_list.Items.Clear(); httpReq = (HttpWebRequest)WebRequest.Create(m_url.Text); httpResp = (HttpWebResponse)httpReq.GetResponse(); httpStream = httpResp.GetResponseStream(); int count = httpStream.Read(buf, 0, buf.Length); httpStream.Close(); string tempstr = ASCII.GetString(buf, 0, count); ChangeLfToCrLf(ref tempstr); m_results.Text = tempstr; for(int i=0; i < httpResp.Headers.Count; ++i) m_header_list.Items.Add( httpResp.Headers.Keys[i] + " = " + httpResp.Headers[i]); for(int i=0; i< httpResp.Cookies.Count; i++) m_cookie_list.Items.Add( httpResp.Cookies[i]); } catch (Exception except) { m_results.Text = "Generic Exception: {0}" + except.Message.ToString(); } MessageBeep(10000); }