/// <summary> /// Parsing received data /// </summary> public void parse() { //buffer = m_headerIn.Substring(0, m_headerIn.IndexOf('\n')); if (HeaderIn.Contains("GET")) { Result = methodGetParse(HeaderIn); } else if (HeaderIn.Contains("HEAD")) { methodHeadParse(HeaderIn); } // ERROR HEADER else { Head mh = new Head(); Result.Header = mh.createHeader(500); } }
/// <summary> /// POST parse method /// </summary> /// <param name="postData">Post data sent by the browser</param> public void parse(string postData) { string buf = ""; buf = HeaderIn.Substring(0, HeaderIn.IndexOf("\r\n")); if (buf.Contains("POST")) { //Post mp = new Post(m_headerIn, postData); //System.Text.Encoding enc = System.Text.Encoding.ASCII; //Result.Response = enc.GetBytes(mp.uruchom()); //mp.createHeader(0, mp.m_filesize); //Result.Header = mp.m_header; //Result.Length = mp.m_filesize; //Result.IsAnswer = true; } else { Head mh = new Head(); Result.Header = mh.createHeader(500); } }
/// <summary> /// Method creates Result object /// </summary> /// <param name="input">Input header</param> private void methodHeadParse(string input) { if (input.StartsWith("HEAD / HTTP")) { input = Settings.DefaultFileName; } else { try { // MAGIC NUMBER 5 MEANS-> LENGTH("HEAD ") // MAGIC NUMBER 6 MEANS-> LENGTH("HEAD /") input = input.Substring(6, input.IndexOf("HTTP/1") - 1 - 6); } catch (Exception) { input = Settings.DefaultFileName; } } Head methodHead = new Head(input); Result.HasContent = false; Result.Header = methodHead.createHeader(0); }