Parsing of HTTP protocol request rules and dotnet

Source: Internet
Author: User
Tags dotnet

The first line of the request method URI Protocol/version request is "Method URL negotiation/version": get/sample.jsp http/1.1 the "GET" in the code above represents the request method, "/sample.jsp" represents the URI, "http/1.1 represents the version of the Protocol and Protocol. HTTP requests can use a variety of request methods, depending on the HTTP standard. For example: HTTP1.1 supports 7 methods of request: GET, POST, HEAD, OPTIONS, PUT, delete, and Tarce. In Internet applications, the most common method is get and post. The       URL completely specifies the network resource to be accessed, usually with a relative directory relative to the root of the server, always beginning with a "/", and finally, the version of the Protocol that declares the use of HTTP during communication. The   Request header request header contains many useful information about the client environment and the request body.    For example, the request header can declare the language used by the browser, the length of the request body, and so on. accept:image/gif.image/jpeg.*/* ACCEPT-LANGUAGE:ZH-CN connection:keep-alive host:localhost USER-AGENT:MOZILA/4 .0 (Compatible:msie5.01:windows NT5.0) accept-encoding:gzip,deflate.  a blank line between the request body request header and the request body, this line is very important, it means that the request header has ended, Next is the request body. The request body can contain query string information submitted by the customer: username=jinqiao&password=1234 in the HTTP request for the example above, the body of the request has only one line of content.  Of course, in real-world applications, the HTTP request body can contain more content. HTTP request method I only discuss the Get method with the Post method L         get method The Get method is the default HTTP request method, We use the Get method to submit the form data on a daily basis, but the form data submitted with the Get method is simply encoded, and it is sent to the Web server as part of the URL, so there is a security risk if you use the Get method to submit the form data. For exampleHttp://127.0.0.1/login.jsp?Name=zhangshi&Age=30&Submit=%cc%E+%BD%BBFrom the URL request above, it is easy to identify what the form submits. (? Later) Additionally, the amount of data submitted is not too large because the data submitted by the Get method is part of the URL request. The Post method is an alternative to the Get method, which is primarily to submit form data to the Web server, especially large batches of data. The Post method overcomes some of the drawbacks of the Get method. When submitting form data through the Post method, the data is not sent as part of the URL request but as standard data to the Web server, which overcomes the drawback that the information in the Get method is not confidential and the amount of data is too small.  Therefore, for security reasons and respect for user privacy, the Post method is usually used for form submission. From a programmatic point of view, if a user submits data through a GET method, the data is stored in the QUERY_STRING environment variable, and the data submitted by the Post method can be obtained from the standard input stream.  Analyze the common httpreuest objects of several dotnet: System.Web.HttpRequest should be the most comprehensive object: QueryString: A System.Collections.Specialized.NameValueCollection that contains a collection of query string variables sent by the client.  For example, if the request URL is http://www.contoso.com/default.aspx?id=44,System.Web.HttpRequest.QueryString with a value of "id=44"; Form: Httpreuest can self-parse the source of the parameter, and put the final parameter into the form; the most primitive form stream in inputstream:body;

Parsing of HTTP protocol request rules and dotnet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.