URL: Unifrom Resource Locator
URL scheme: scheme
Server address: Ip:port
Resource path:
http://www.magedu.com:80/bbs/index.php
Basic syntax:
<scheme>://<user>:<password>@
params: Parameters
HTTP protocol: Stateless stateless
Server does not continuously track visitor sources
cookie,session Track and save user browsing information,
HTTP transaction:
requests: request
Response: Response
Message Syntax format :
Request message:
<method> <request-URL> <version> # start line
<entity-body> #实体
Response message:
<version> <status> <reason-phrase>
Status Code reason phrase
<entity-body>
<method>: Request method, desired action on server side, such as, post, etc.
Get: Get a resource from the server
HEAD: Get the document's response header from the server only
POST: Send the data to the server for processing:
Put: Stores the body portion of the request on the server,
Delete: Request to delete the specified document on the server
TRAACE: Tracking request arrives at the Server intermediate proxy server
OPTIONS: Request server returns the request method used for the specified resource support
<request-url>: Requested resource, can be a relative path, or it can be a full URL
<version>: protocol version, Format http/<major>. <minor>, as http/1.0
: HTTP Header
<status>: status code
<reason-phrase>: Cause phrase, number status, easy-to-read information
<entity-body>: The main part
Tools for viewing or analyzing protocols:
Tcpdump,tshark,wireshark
version:http/<major>.<minor>
Status (state code):
Three digits, such as 200,301,302,404,502; Mark what happens during request processing
1XX: Information Alert status Code
100-101
2XX: Success Status Code
200:ok
201:created OK
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
reason-phrase: A brief description of the status marked by the status code
headers: Each request or response message can contain any header, each header has a header name, followed by a colon and followed by an optional space followed by a value
entity-body: data when the request is attached to the data or response
Headers ( HTTP header) Classification:
Format:
Name:value
General Header :
Date: The time the message was created
Connection: Connection mode, e.g. keep-alive
Via: Displays the middle node through which the message passed
Cache-control: Controlling the cache
Pragma
Request Header
The user indicates that the customer is more inclined to support the use of the ability
Accept: Notifies the server of the type of media it can receive
Accept-charset: Character Set
Accept-encoding: Notifies the server of the encoding format it can receive itself. such as Gzip
Accept-language: Language
Informational Request Header:
CLIENT-IP:
Host: The requested server name and port number
Referer: Contains the top level resource for the resource that is currently being requested
User-agent: Client proxy type
Conditional Request Header:
Expect: Expected behavior
If-modified-since: Whether this resource has been modified since the specified time
If-unmodified-since:
If-none-match: The file etag label stored in the local cache does not match the server
If-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
Proxy Request Header:
Proxy-authorization: Authenticating to a proxy server
Response Header
Age: Duration of response
Server: Indicates to the client the name and version of the servers program
Negotiation header: Used when a resource has multiple and presentation methods
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
The length of the contern-length entity
Contern-type Object Types for entities
Contern-range where the entity is actually located
Contern-location
Cache Header:
ETag: Extended label for entity
Expires: Entity Expiration label
Last-modified: Last Modified time
Extension header
Second, Curl command
Curl is a file transfer tool that works in command-line mode based on URL syntax, which supports protocols such as FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, file, and LDAP. Curl supports HTTPS authentication, and supports HTTP post, put and other methods, FTP upload, Kerberos authentication, HTTP upload, proxy server, cookies, username/password Authentication, download file breakpoint continuation, upload file breakpoint continuation,, HTTP proxy Server pipeline (proxy tunneling), even it supports IPV6, SOCKS5 proxy server, upload files via HTTP proxy server to FTP server and so on, the function is very powerful.
common options for Curl :
Grammar:
curl [Options] [URL ...]
-a/--user-agent <string> set user agent to send to server, that is, tell the server browser type
-basic using HTTP Basic authentication
--tcp-nodelay using the Tcp_nodelay option
-e/--referer <URL> Source URL, jump over the URL
--cacert <file> Specify CA certificate (SSL)
--compressed requirements Return is a compressed situation, if the file itself is a compressed file, you can download to the local
-h/--header <line> Custom header information to the server
-i/--head only the response message header information is displayed
--limit-rate <rate> Set Transfer speed
-u/--user <user[:p assword]> setting up the user and password for the server
-0/--http1.0 Using HTTP 1.0
Another tool: ELinks
ELinks [OPTION] ... [URL] ...
-dump: does not enter interactive mode, but directly outputs the contents of the URL to standard output
Three, Mod_deflate module
Use the Mod_deflate module to compress the page to optimize the transfer speed, can be written as a line, you can write multiple lines, the default is gzip
Applicable scenarios:
(1) Save bandwidth, additional CPU consumption, may be some older browsers do not support
(2) Compress resources that are suitable for compression, such as text files
setoutputfilter deflate# mod_deflate configuration # restrict compression To these mime typesaddoutputfilterbytype deflate text/plainaddoutputfilterbytype deflate text/htmladdoutputfilterbytype deflate application/xhtml+xmladdoutputfilterbytype DEFLATE text/xmlAddOutputFilterByType DEFLATE application/xmlAddOutputFilterByType deflate application/x-javascriptaddoutputfilterbytype deflate text/ javascriptaddoutputfilterbytype deflate text/css # level of compression ( highest 9 - lowest 1) defaults to 6deflatecompressionlevel 9 # netscape 4.x has some problems. Browsermatch ^mozilla/4 gzip-only-text/html # netscape 4.06-4.08 have some more problemsbrowsermatch ^mozilla/4\.0[678] no-gzip # msie masquerades as netscape, but it is finebrowsermatch \bmsi[e] !no-gzip !gzip-only-text/html
Web:3, httpd message Syntax format