What is HTTP?
HTTP is a protocol which allows the fetching of resources, such as HTML documents.
Foundation of any data exchange on the Web and it is a client-server protocol.
Clients and servers communicate by exchanging individual messages .
Messages sent by the client are called requests.
Messages sent by the server as an answer are called responses.
Application layer protocol that is sent over TCP, or over a TLS-encrypted TCP
connection.
Transport Layer Security, or TLS, is a widely adopted security protocol designed to facilitate privacy and
data security
for communications over the Internet. A primary use case of TLS is encrypting
the communication between web applications and servers, such as web
browsers loading a website.
Not only fetch hypertext documents, but also images and videos or to post
content to servers, like with HTML form results.
The Transmission Control Protocol (TCP) is one of the main protocols of the Internet protocol suite.
Network implementation in which it complemented the Internet Protocol (IP). TCP/IP.
TCP provides reliable, ordered, and error-checked delivery of a stream
of octets (bytes) between applications running on hosts communicating
via an IP network.
Internet applications (World Wide Web, email, remote administration, and
file transfer)
rely on TCP, which is part of the Transport Layer of the TCP/IP suite. SSL/TLS
often runs on top of TCP.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
A Google Cloud Function can be called in response to multiple types of events, and of
the most useful events to use is an HTTP request.
Make a GET, POST or other HTTP request to a URL provided by your Cloud Function,
and have it run in response to the given request.
HyperText Transfer Protocol (HTTP)
HTTP is an asymmetric request-response client-server protocol.
Sends a request message to an HTTP server.
Returns a response message.
Browser
Issue a URL from your browser to get a web resource using HTTP,
Browser turns the URL into a request message
Sends it to the HTTP server.
Server interprets the request message.
Returns you an appropriate response message.
Uniform Resource Locator (URL)
A URL (Uniform Resource Locator) is used to uniquely identify a resource over the web.
URL has the following syntax:
protocol://hostname:port/path-and-file-name
There are 4 parts in a URL:
Protocol: The application-level protocol used by the client and server,e.g., HTTP, FTP, and telnet.
Hostname: The DNS domain name (e.g., www.nowhere123.com)
or IP address (e.g., 192.128.1.2) of the server.
Port: The TCP port number that the server is listening for incoming
requests from the clients.
Path-and-file-name: The name and location of the requested
resource, under the server document base directory.
The port number was not specified in the URL, and takes on the default number,
which is TCP port 80 for HTTP. The path and file name for the resource to be located
is "/docs/index.html".
Other examples of URL are:
ftp://www.ftp.org/docs/test.txt
mailto:user@test101.com
news:soc.culture.Singapore
telnet://www.nowhere123.com/
HTTP Protocol
URL in the address box of the browser.
Translates the URL into a request message.
GET /docs/index.html HTTP/1.1
Host: www.nowhere123.com
Accept: image/gif, image/jpeg, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
(blank line)
When this request message reaches the server, the server can take either one of these
actions:
The server interprets the request received, maps the request into a file under
the server's document directory, and returns the file requested to the client.
The server interprets the request received, maps the request into a program
kept in the server, executes the program, and returns the output of the
program to the client.
The request cannot be satisfied, the server returns an error message.
An example of the HTTP response message is as shown:
HTTP/1.1 200 OK
Date: Sun, 18 Oct 2009 08:56:53 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Sat, 20 Nov 2004 07:16:26 GMT
ETag: "10000000565a5-2c-3e94b66c2e680"
Accept-Ranges: bytes
Content-Length: 44
Connection: close
Content-Type: text/html
X-Pad: avoid browser bug
<html><body><h1>It works!</h1></body></html>
The browser receives the response message, interprets the message and displays the
contents of the message on the browser's window according to the media type of the
response (as in the Content-Type response header). Common media type include
"text/plain", "text/html", "image/gif", "image/jpeg", "audio/mpeg", "video/mpeg",
"application/msword", and "application/pdf".
In its idling state, an HTTP server does nothing but listening to the IP address(es) and
port(s) specified in the configuration for incoming request.
HTTP Request and Response Messages
HTTP client and server communicate by sending text messages. The client sends a
request message to the server. The server, in turn, returns a response message.
HTTP Request Message
The format of an HTTP request message is as follow:
Request Line
The first line of the header is called the request line, followed by optional request headers.
The request line has the following syntax:
request-method-name request-URI HTTP-version
request-method-name: HTTP protocol defines a set of request methods, e.g.,
GET, POST, HEAD, and OPTIONS. The client can use one of these methods to
send a request to the server.
request-URI: specifies the resource requested.
HTTP-version: Two versions are currently in use: HTTP/1.0 and HTTP/1.1.
Examples of request line are:
GET /test.html HTTP/1.1
HEAD /query.html HTTP/1.0
POST /index.html HTTP/1.1
Request Headers
The request headers are in the form of name:value pairs. Multiple values,
separated by commas, can be specified.
request-header-name: request-header-value1, request-header-value2, ...
Examples of request headers are:
Host: www.xyz.com
Connection: Keep-Alive
Accept: image/gif, image/jpeg, */*
Accept-Language: us-en, fr, cn
Example
The following shows a sample HTTP request message:
HTTP Request Methods
HTTP protocol defines a set of request methods. A client can use one of these request
methods to send a request message to an HTTP server. The methods are:
GET: A client can use the GET request to get a web resource from the server.
HEAD: A client can use the HEAD request to get the header that a
GET request would have obtained. Since the header contains the
last-modified date of the data, this can be used to check against the
local cache copy.
POST: Used to post data up to the web server.
PUT: Ask the server to store the data.
DELETE: Ask the server to delete the data.
TRACE: Ask the server to return a diagnostic trace of the actions
it takes.
OPTIONS: Ask the server to return the list of request methods it
supports.
CONNECT: Used to tell a proxy to make a connection to another
host and simply reply the content, without attempting to parse or cache it. This is often used to make SSL connection through the proxy.
Other extension methods.
"GET" Request Method
GET is the most common HTTP request method. A client can use the
GET request method to request (or "get") for a piece of resource from an HTTP server.
A GET request message takes the following syntax:
GET request-URI HTTP-version
(optional request headers)
(blank line)
(optional request body)
No comments:
Post a Comment