• Tidak ada hasil yang ditemukan

ILO2-HTTP Protocol and Methods

N/A
N/A
@Muhammad J. Abu-Emaish

Academic year: 2024

Membagikan "ILO2-HTTP Protocol and Methods"

Copied!
30
0
0

Teks penuh

(1)

ILO2_HTTP protocol and

methods

(2)

Network Programming involves writing programs that communicate with other ..

. applications to connect to one another using RMI (remote method invocation). ...

Here, http:// is the protocol identifier which indicates the protocol that will be used

(3)
(4)

• The common Different Types of Networking Protocols

Internet Protocol (IP)

User Datagram Protocol (UDP)

Transmission Control Protocol (TCP)

FTP (File Transfer Protocol) ...

Email Protocols (POP3, IMAP, SMTP) ...

(5)

HTTP protocol definitions

• Hypertext Transfer Protocol is used to transfer data over the web

HTTP is a protocol which allows the fetching of resources, such as HTML documents.

• It is the foundation of any data exchange on the Web and it is a client- server protocol, which means requests are initiated by the recipient, usually the Web browser.

HTTP uses a server-client model.

• A client, for example, may be a home computer, laptop, or mobile device.

• The HTTP server is typically a web host running web server software, such as Apache or IIS.

(6)

• Hypertext Transfer Protocol Secure (HTTPS) is an extension of the Hypertext Transfer Protocol (HTTP).

• It is used for secure communication over a computer network, and is widely used on the Internet

(7)

The Basic Characteristics of HTTP (Hyper Text Transfer Protocol):

• It is the protocol that allows web servers and browsers to exchange data over the web.

• It is a request response protocol.

• It uses the reliable TCP connections by default on TCP port 80.

• It is stateless means each request is considered as the new request.

(8)

As a summary of HTTP function:

• HTTP is a generic and stateless (homless) protocol which can be used for other purposes as well using extensions of its request methods, error codes, and headers. Basically, HTTP is a TCP/IP based

communication protocol, that is used to deliver data (HTML files, image files, query results, etc.) on the World Wide Web.

HTTP is called as a stateless protocol because each request is

executed independently, without any knowledge of the requests that were executed before it, which means once the transaction ends the connection between the browser and the server is also lost.

(9)

HTTP operation

• HTTP is a connectionless text based protocol.

• Clients (web browsers) send requests to web servers for web elements such as web pages and images.

• After the request is serviced by a server, the connection between client and server across the Internet is disconnected.

• A new connection must be made for each request.

(10)

Step 1: Establishing a TCP connection to the server by the client. ...

Step 2: Initiating a HTTP GET Request by the client to the server. ...

Step 3: HTTP Server Response to a HTTP GET Request.

(11)

• The most common methods are GET and POST.

• But there are a few others, too.

• GET — You use this method to request data from a specified resource where data is not modified it in any way.

• GET requests do not change the state of resource

(12)

Does HTTP use TCP or UDP

HTTP uses TCP because the files, images, web pages which we get from the remote host should not be dropped on the way and it should be delivered in order to the HTTP client.

HTTP could also use UDP but usually not, if a UDP packet containing the first part of a web page is lost, then its not retransmitted.

(13)

HTTP method (or verbs)

• The set of common methods for HTTP/1.1 is defined below and this set can be expanded based on requirements.

• These method names are case sensitive and they must be used in uppercase.

• The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, PATCH, and DELETE.

These correspond to create, read, update, and delete (or CRUD) operations, respectively.

• There are a number of other verbs, too, but are utilized less frequently.

(14)

GET method or verb

• The GET method is used to retrieve information from the given server using a given URL.

• Requests using GET should only retrieve data and should have no other effect on the data

(15)

GET Method example

A GET request retrieves data from a web server by specifying parameters in the URL portion of the request.

This is the main method used for document retrieval. The following example makes use of GET method to fetch hello.htm:

GET /hello.htm HTTP/1.1

User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.com

Accept-Language: en-us

Accept-Encoding: gzip, deflate Connection: Keep-Alive

(16)

• The server response against the above GET request will be as follows:

HTTP/1.1 200 OK

Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache/2.2.14 (Win32)

Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT ETag: "34aa387-d-1568eb00"

Vary: Authorization,Accept Accept-Ranges: bytes

Content-Length: 88

Content-Type: text/html Connection: Closed

<html>

<body>

<h1>Hello, World!</h1>

</body>

</html>

(17)

HEAD method

• HEAD method Same as GET, but transfers the status line and header section only

• The HEAD method is functionally similar to GET, except that the

server replies with a response line and headers, but no entity-body.

(18)

POST method

• A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.

• The POST method is used when you want to send some data to the server, for example, file update, form data, etc.

• The following example makes use of POST method to send a form

data to the server, which will be processed by a process.cgi and finally a response will be returned:

(19)
(20)

The server response against the above GET request will be as follows:

(21)

PUT method

• Replaces all current representations of the target resource with the uploaded content.

• The PUT method is used to request the server to store the included entity-body at a location specified by the given URL.

• The following example requests the server to save the given entity- body in hello.htm at the root of the server:

(22)
(23)

DELETE method

• The DELETE method is used to request the server to delete a file at a location specified by the given URL.

• Removes all current representations of the target resource given by a URI

• The following example requests the server to delete the given file hello.htm at the root of the server:

(24)
(25)

CONNECT method

• The CONNECT method is used by the client to establish a network connection to a web server over HTTP.

• Establishes a tunnel to the server identified by a given URI.

• The following example requests a connection with a web server running on the host tutorialspoint.com:

(26)
(27)

OPTION method

• The OPTIONS method is used by the client to find out the HTTP methods and other options supported by a web server.

• The client can specify a URL for the OPTIONS method, or an asterisk (*) to refer to the entire server.

• Describes the communication options for the target resource.

• The following example requests a list of methods supported by a web server running on tutorialspoint.com:

(28)
(29)

TRACE method

• The TRACE method is used to echo the contents of an HTTP Request back to the requester which can be used for debugging purpose at the time of development.

• Performs a message loop-back test along the path to the target resource.

• The following example shows the usage of TRACE method:

(30)

Referensi

Dokumen terkait