What is HTTP?
The Hypertext Transfer Protocol (hypertext Transfer Protocol-HTTP) is a protocol designed to enable clients and servers to communicate smoothly.
The HTTP request method provided by the HTTP/1.1 protocol has options,, POST, PUT, DELETE, TRACE, CONNECT.
GET Request Response
A GET request displays the resource that the request specifies. Generally the Get method should only be used for reading data. The Get method requests the specified page information and returns the response body, and get is considered an unsafe method because the Get method is accessed arbitrarily by the network spider. When you use the Get method, the query string (the key-value pair) is appended to the URL address and sent to the server:/test/demoform.html?name1=value1&name2= Value2 features: A GET request can be cached by a GET request that is saved in the browser's browsing record as a GET request URL can be saved as a browser bookmark GET request has a length limit GET request is primarily used to obtain data
Post sends data to the server for processing
Post sends data to the server for processing, the data is contained in the HTTP message body, the POST request submits data to the specified resource, requests the server for processing, such as: Form data submission, file upload, and so on, the request data is included in the request body. The Post method may create a new resource or //test/demoform.html http/1.1Host:w3schools.comname1=value1 &name2=value2 Features: Post request cannot be cached POST request is not saved in browser browsing record as POST request URL cannot be saved as browser bookmark POST request no length limit
Head is the same response as get, only requires a response header
Head with Get the same response, only requires the response header the head method, like the Get method, is a request to the server to issue the specified resource. However, the server does not return the content part of the resource in response to the head request, that is, the response body. In this way, we can get the server's response header information without transmitting the entire content. The head method is often used by clients to view the performance of the server.
PUT to upload files.
A put request uploads its latest content to the specified resource location, and the Put method is a idempotent method. This method allows the client to transfer the most recent data from the specified resource to the server in place of the specified resource's content.
Delete deleting files
The delete request is used to request the server to delete the resource identified by the requested URI (Uniform Resource Identifier, Uniform Resource Identifier). Deletes the specified resource after the delete request, and the Delete method is idempotent.
Connect converts HTTP request connections into a transparent tcp/IP channel
The Connect method isreserved for the HTTP/1. 1 protocol and is capable of changing the connection to a pipe-mode proxy server. A link to an SSL-encrypted server is typically used to communicate with a non-encrypted HTTP proxy server.
Trace tracking of requests received
Trace requests the server to echo its received request information, which is used primarily for testing or diagnosing HTTP requests.
Options how to return HTTP requests supported by the server
The options request is similar to head and is typically used for client View server performance. This method requests the server to return all the HTTP request methods supported by the resource, which uses '*' instead of the resource name to send the options request to the server. You can test whether the server functions properly. When a JavaScript XMLHttpRequest object is shared with a cors cross-domain resource, the options method is used to send a sniffer request to determine whether there is access to the specified resource.
There is also an architectural style: RESTful. Rest (English: Representational State Transfer, abbreviated as REST) describes a schema-style network system, such as a Web application.
REST refers to a set of schema constraints and principles. Applications or designs that meet these constraints and principles are RESTful.
The HTTP protocol is an ASCII code-basedApplication layer specification based on the tcp/IP protocol. The specification divides the HTTP request into three parts: a status line, a request header, and a message body. Similar to the following:<method> <request-URL> <version>What encoding does the data use, Developers can decide the format of the message body by themselves, as long as the last HTTP request satisfies the above format. However, the data sent out, but also the service side of the success of the analysis is meaningful. The server is usually informed by the Content-type field in the request header (headers)How the message body in the request is encoded, and then the principal is parsed.
Common Enctype properties in form
application/x-www-form-<form> form, if you do not set the Enctype property, you will end up with application/x-www-form- Urlencoded way to submit data. The submitted datais encoded according to the Key1 =val1&key2=val2, and both key and Val are URL-transcoded. Multipart/form-<form> form, you need to set the Enctype property, when the form uploads the file, the enctyped of the <form> form must be equal to multipart/ Form-data.
The common content-Type in Ajax
Application/JSON is used to tell the server that the message body is a serialized JSON string. Json.stringify (str);//Convert a JSON object to a JSON characterJson.parse (str);//convert from JSON string to JSON objectJSON Objectvaruser = {"FirstName":"Jason","LastName":"Hua"}user.firstname//Accessing DataJSON ArrayvarDepartment = { "Employees": [ { "FirstName":"Jason","LastName":"Hua" }, { "FirstName":"Jason","LastName":"Hua" } ], "Department":"Dev"}department.employees[0].firstname//Accessing Data
Http content-type Table: http://tool.oschina.net/commons
HTTP protocol Introduction (POST, GET, Content-type)