Getting Started with HTTP

Source: Internet
Author: User

HTTP www Internet

---

# #URI: Uniform Resource Identifiers
URL: Uniform Resource Locator
URN: Uniform Resource Name

# #HTTP: Hypertext Transfer Protocol
# # #HTTP请求:
Curl-s-v-h "Muxue:xxx"--"https://www.baidu.com"
Create a request with curl and get a response
Create a request with curl and get a response
The requested content is

> get/http/1.1
> Host:www.baidu.com
> user-agent:curl/7.58.0
> Accept: */*
> muxue:xxx
>

Curl-x post-s-v-h "muxue:xxx"--"https://www.baidu.com"
The requested content is

> post/http/1.1
> Host:www.baidu.com
> user-agent:curl/7.58.0
> Accept: */*
> muxue:xxx
>

Curl-x post-d "1234567890"-s-v-H "muxue:xxx"--"https://www.baidu.com"
The requested content is

> post/http/1.1
> Host:www.baidu.com
> user-agent:curl/7.58.0
> Accept: */*
> muxue:xxx
> Content-length:10
> content-type:application/x-www-form-urlencoded
>

>1234567890
The request contains a maximum of four parts, with a minimum of three. (That is, part four can be empty)
The third part is always a carriage return (\ n)
Verb has get POST PUT PATCH DELETE HEAD OPTIONS etc.
The path here includes "query parameters", but does not include "anchor points"
If you do not write the path, the path defaults to/
The Content-type in part 2nd marks the 4th part of the format

# # #用 Chrome sends a request
Open Network
Address field input URL
Click on Network, view request, click "view source"
Click "view source"
Click "view source"
Click "view source"
You finally ordered it? You can see the first three parts of the request.
If you have the fourth part of the request, you can see it in FormData or Payload
Response
After the request, you should be able to get a response, unless the network is disconnected, or the server is down.

# # #响应示例
The above three request examples, the first two requests correspond to the response of the

< http/1.1 OK
< Accept-ranges:bytes
< Cache-control:private, No-cache, No-store, Proxy-revalidate, No-transform
< connection:keep-alive
< content-length:2443
< content-type:text/html
< Date:sat, Mar 2018 10:07:20 GMT
< Etag: "588603eb-98b"
< Last-modified:mon, 13:23:55 GMT
< Pragma:no-cache
* Server bfe/1.0.8.18 is not blacklisted
< server:bfe/1.0.8.18
< set-cookie:bdorz=27315; max-age=86400; domain=.baidu.com; path=/
<

<!DOCTYPE html>.......

< http/1.1 302 Found
< connection:keep-alive
< content-length:17931
< content-type:text/html
< Date:sat, Mar 2018 10:07:59 GMT
< Etag: "54d97487-460b"
* Server bfe/1.0.8.18 is not blacklisted
< server:bfe/1.0.8.18
<

<


Format of the response
Protocol/Version Number status code state explanation
Key1:value1
Key2:value2
content-length:17931
Content-type:text/html

Status code to back, is the server to the browser said
1XX not used
2XX indicates success
3xx means roll.
4xx means you're wrong.
5xx means okay, I'm wrong.
State explanation doesn't work.
The Content-type in part 2nd marks the 4th part of the format
The Content-type in the 2nd part follows the MIME specification
View responses in Chrome
Open Network
Enter URL
Select the first response
View Response Headers, click "view source", click "view source", click "view source"
You'll see the first two parts of the response
Check out Response or Preview and you'll see the 4th part of the response

Curl is a file transfer tool that works in command-line mode based on URL syntax, and supports protocols such as Ftp,ftps,http,https,gopher,telnet,dict,file and LDAP.

Curl support HTTPS authentication, and support HTTP post,put methods, FTP upload, HTTP upload, proxy server, cookies, username/password authentication, upload files via HTTP proxy server to FTP server, etc.

Too powerful to digest, for the time being.

Getting Started with HTTP

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.