Web Service:http Protocol

Source: Internet
Author: User

First, the basic concept of HTTP protocol

Hypertext Transfer Protocol (Http,hypertext Transfer Protocol) is one of the most widely used network protocols on the Internet. All WWW documents must comply with this standard. HTTP was originally designed to provide a way to publish and receive HTML pages.

1. Sockets

(1) Definition of sockets

Socket, which is the basic operation unit of TCP/IP-supported network communication, can be regarded as the endpoint of two-way communication between different hosts, which is simply a kind of convention of communication, and the correlation function in socket is used to complete the communication process.

(2) Classification of sockets

The 3 types of sockets for commonly used TCP/IP protocols are as follows:

① stream Sockets (SOCK_STREAM):

Stream sockets are used to provide connection-oriented, reliable data transfer services. The service will ensure that the data can be error-free, non-repeatable, and sequentially received. A streaming socket is capable of achieving reliable data services because it uses the transmission Control protocol, the TCP (the Protocol) transmission.

② datagram Sockets (SOCK_DGRAM):

Datagram sockets provide a non-connected service. The service does not guarantee the reliability of data transmission, it is possible to lose or duplicate data during transmission, and can not guarantee the sequential receipt of data. Datagram sockets use the UDP (User Datagram Protocol) protocol for data transfer. Due to the fact that datagram sockets cannot guarantee the reliability of data transmission, it is necessary to do the corresponding processing in the program in case of possible loss.

③ Original Socket (SOCK_RAW):

Raw Sockets (Socket_raw) allow direct access to lower-level protocols, such as IP, ICMP protocol, which is often used to verify new protocol implementations, or to access new devices configured in existing services, because RAW sockets have the freedom to control multiple protocols under Windows. can control the transmission mechanism of the network bottom, so the original socket could be applied to manipulate the network layer and the Transport layer application.

2.http Protocol version

Hypertext transfer protocols have evolved in many versions, most of which are backwards compatible.

0.9 is obsolete, accepts only get one request method, does not specify the version number in the communication, and does not support the request header. Because this version does not support the POST method, clients cannot pass too much information to the server.

Http/1.0 This is the first HTTP protocol version that specifies the version number in the newsletter and is still widely used, especially in proxy servers.

http/1.1 the current version, persistent connections are adopted by default and can work well with proxy servers. It also supports the simultaneous sending of multiple requests in a piped manner to reduce line load and increase transmission speed.

Spdy: Accelerates the browser to get the resource speed.

http/2.0: The benefits of consolidating the SPDY protocol.

3.MIME

MIME (Multipurpose Internet Mail Extensions) multi-purpose Internet Mail extension type. Is the type of file that sets the extension of an application to be opened by an app, and when the extension file is accessed, the browser automatically opens with the specified application. Many are used to specify some client-customized file names, as well as some ways to open media files.

NASE64: Encodes binary data into text and enables the recipient to revert back to its original format.

Second, HTTP message format and request method

1.http Method:

Secure method:

POST, PUT, DELETE, OPTIONS, TRACE

Extension methods: LOCK, MKCOL, COPY, MOVE

Get: Request for a resource that requires a server to send

HEAD: Similar to get, but it does not require a service to send resources and only returns the response header

POST: Support HTML form submission, the form has the user fill in the data, the data will be sent to the server side, stored by the server to a location (such as the Send handler)

PUT: Writes a document to a service, as opposed to get; Publish system

Delete: request to delete the resource that the URL points to

Options: Probing server-side request methods supported by a resource

Trace: A firewall, proxy, or gateway that tracks requests for resources

2.http Message Format

HTTP transaction: The response of a request to its counterpart.

(1) HTTP request message Format:

<method><request-url><version> #< obtained method >< requested resource >


<entity-body> #< message body >

(2) HTTP response message format:

<version><status><reason-phrase> #


<entity-body> #< message body >

(3) HTTP protocol header:

Divided into three categories: The general header, the request header and the response header.

(4) HTTP Response message code

1XX: Informational Status code

2XX: Success Status Code

3XX: Redirect Status code

301:moved permanebtly Permanent redirect, using the header "Location:url" in the response message to specify where the resource is now

302:found temporary redirect, specifying the temporary resource location using the header "Location:url" in the response message

304:not Modified, using in conditional requests

4XX: Client-side error

403:forbidden, request rejected by server

404:not Found, the server could not find the requested URL

405:method not allowed, which does not allow a URL to request a response using this method

5XX: Error in server class

500:internal server error, internal errors

502:bad Gateway: Proxy server receives a pseudo response from upstream

503:service unavailable, the server cannot provide services at this time, but may be available in the future

(5) HTTP header

Divided into five categories: general header, request header, response header, entity header, and extension header.

① General Header:

Connection: Defines the relevant options for request/response between C/s

For Http/1.0,connection Keep-alibe

Via: Shows the middle node of the message passing through

Cache-control: Cache Indication

② Request Header:

CILENT-IP: request-side IP

Host: the hostname and port number of the request, used for different virtual hosts under the virtual host environment

Referer: Indicates the URL of the original resource that requested the current resource

User-agent: User agent, what tools are used to make requests

Accept the first: the user indicates that the customer is more inclined to support the use of the ability

Accept: Indicates the type of media that the server can send

Accept-charset: Supported character sets for use

Accept-encoding: Supported encoding method

Accept-language: Support for language use

③ Conditional Request Header:

Expect: Expected behavior

If-modified-since: Whether this resource has been modified since the specified time

If-none-match

Security-related request header:

Authorication: Authentication data that the client submits to the server, such as account number and password

Cookie: Client sends to server-side ID

Cookie2

④ Response Header:

Age: Duration of response

Server: Indicates to the client the name and version of the servers program

⑤ Negotiation Header:

Accept-ranges: The types of scopes that the server can accept for the current resource

Vary: The first list, the server will pick the most appropriate version according to the contents of the list sent to the client

Security-related response header

Set-cookie: Server-side token issued by a client on first request

Set-cookie2:

Www-authenication: Ask the client for an account and password

⑥ Entity Header:

Location: New Locations for resources

Allow: A request method that allows the use of this resource

Content Header:

Contern-encoding

Contern-language

Contern-length

Contern-type

Contern-range

Contern-location

⑦ Cache Header:

ETAG: Entity label

Expires: Expired Label

Last-modified: Last Modified time

Web Service:http Protocol

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.