fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Net;
  6. using System.IO;
  7.  
  8. class http
  9. {
  10. static void Main(string[] args)
  11. {
  12. var gallid = "programming";
  13. var gallnum = "" + 404863;
  14.  
  15. HttpWebRequest client = WebRequest.Create("http://g...content-available-to-author-only...e.com/board/view/?id="+gallid+"&no=" + gallnum) as HttpWebRequest;
  16. HttpWebResponse res = client.GetResponse() as HttpWebResponse;
  17.  
  18. var cookCode = res.GetResponseHeader("Set-Cookie");
  19. int st = cookCode.IndexOf("ci_c=") + 5;
  20.  
  21. cookCode = cookCode.Substring(st, 32);
  22. Console.WriteLine(cookCode);
  23.  
  24. StringBuilder PostContent = new StringBuilder();
  25.  
  26. PostContent.Append("id=" + gallid);
  27. PostContent.Append("&no=" + gallnum);
  28. PostContent.Append("&memo=" + "test");
  29. PostContent.Append("&ci_t=" + cookCode);
  30. PostContent.Append("&name=" +"dd");
  31. PostContent.Append("&password=" + "123123");
  32.  
  33.  
  34. byte[] bp = Encoding.UTF8.GetBytes(PostContent.ToString());
  35.  
  36.  
  37. HttpWebRequest httpPost = HttpWebRequest.Create("http://g...content-available-to-author-only...e.com/forms/comment_submit") as HttpWebRequest;//WebRequest.Create("http://g...content-available-to-author-only...e.com/forms/comment_submit") as HttpWebRequest;
  38. httpPost.Method = "POST";
  39. httpPost.KeepAlive = true;
  40. httpPost.ContentLength = bp.Length;
  41. httpPost.Accept = "*/*";
  42. httpPost.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
  43. httpPost.Headers.Add("Accept-Language",
  44. "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
  45. httpPost.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
  46. httpPost.Headers.Add("Origin", "http://g...content-available-to-author-only...e.com");
  47. httpPost.Referer =
  48. "http://g...content-available-to-author-only...e.com/board/view/?id=" + gallid + "&no=" + gallnum;
  49. httpPost.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36";
  50. httpPost.Headers.Add("X-Requested-With", "XMLHttpRequest");
  51.  
  52. httpPost.Expect = null;
  53.  
  54. using (var stream = httpPost.GetRequestStream())
  55. {
  56. stream.Write(bp, 0, bp.Length);
  57. stream.Close();
  58. }
  59.  
  60. res = httpPost.GetResponse() as HttpWebResponse;
  61. System.IO.StreamReader instream = new System.IO.StreamReader(res.GetResponseStream());
  62. Console.WriteLine(instream.ReadToEnd());
  63. }
  64.  
  65. }
  66.  
  67.  
Runtime error #stdin #stdout #stderr 0.23s 42544KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Unhandled Exception: System.Net.WebException: Error: NameResolutionFailure
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
  at http.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.WebException: Error: NameResolutionFailure
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
  at http.Main (System.String[] args) [0x00000] in <filename unknown>:0