HTTP (Hypertext Transfer Protocol) is a protocol for transmitting hypermedia documents across the internet. It uses request-response messages to transfer files and data between clients and servers, with common ports being 80 and 443. HTTP requests use methods like GET, POST, PUT and DELETE and include request headers. Responses include status codes and response headers. RESTful web services apply HTTP methods to perform CRUD (create, read, update, delete) operations on resources identified by URIs.
3. HTTP
Hypertext Transfer Protocol
HTTP는 네트워크 프로토콜 중에 하나로, Hypertext를 전달하
기 위해 사용한다. 현재 가장 많이 쓰이는 HTTP 버전은 1.1이다.
일반적으로 TCP를 사용하나 UDP를 사용하기도 한다.
기본 포트는 80번이다.
Unix System에서 root 가 아닌 경우 1000번 이하의 port를 열
권한이 없어서, 혹은 기타 이유로 8080번의 포트도 자주 사용된
다.
HTTPS의 경우에 443번을 사용한다.
4. HTTP
HTTP Message
HTTP-message = Request | Response ; HTTP/1.1 messages
Request (section 5) and Response (section 6) messages use the
generic message format of RFC 822 for
transferring entities (the payload of the message). Both types of
message consist of a start-line, zero or more header
fields (also known as “headers”), an empty line (i.e., a line with
nothing preceding the CRLF) indicating the end of
the header fields, and possibly a message-body.
generic-message = start-line
*(message-header CRLF)
CRLF
[ message-body ]
start-line = Request-Line | Status-Line
5. HTTP
Message Headers
message-header = field-name ":" [ field-value ]
field-name = token
field-value = *( field-content | LWS )
field-content = <the OCTETs making up the field-value
and consisting of either *TEXT or combinations
of token, separators, and quoted-string>
8. HTTP
Request-Line
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
Method
The Method token indicates the method to be performed on the resource
identified by the Request-URI. The
method is case-sensitive.
Method = "OPTIONS" ; Section 9.2
| "GET" ; Section 9.3
| "HEAD" ; Section 9.4
| "POST" ; Section 9.5
| "PUT" ; Section 9.6
| "DELETE" ; Section 9.7
| "TRACE" ; Section 9.8
| "CONNECT" ; Section 9.9
| extension-method
extension-method = token
9. HTTP
Response
After receiving and interpreting a request message, a
server responds with an HTTP response message.
Response = Status-Line ; Section 6.1
*(( general-header ; Section 4.5
| response-header ; Section 6.2
| entity-header ) CRLF) ; Section 7.1
CRLF
[ message-body ] ; Section 7.2
Status-Line = HTTP-Version SP Status-Code SP Reason-
Phrase CRLF
10. HTTP
Status-Code
1xx: Informational - Request received, continuing process
2xx: Success - The action was successfully received,
understood, and accepted
3xx: Redirection - Further action must be taken in order to
complete the request
4xx: Client Error - The request contains bad syntax or
cannot be fulfilled
5xx: Server Error - The server failed to fulfill an
apparently valid request
13. HTTP
RESTful web services
A RESTful web service (also called a RESTful web API) is a
simple web service implemented using HTTP and the
principles of REST. It is a collection of resources, with four
defined aspects:
The following table shows how the HTTP methods are
typically used to implement a web service.
The PUT and DELETE methods are idempotent methods. The
GET method is a safe method, meaning that calling it produces
no side-effects (this also implies idempotence).
Unlike SOAP-based web services, there is no "official"
standard for RESTful web services. This is because REST is
an architecture, unlike SOAP, which is a protocol. Even though
REST is not a standard, a RESTful implementation such as the
Web can use standards like HTTP, URI, XML, etc.
14. HTTP
RESTful web services
RESTful Web Service HTTP methods
Resource GET PUT POST DELETE
Collection URI, su
ch as http://exam
ple.com/resources
/
List the URIs and p
erhaps other detail
s of the collection's
members.
Replace the entire
collection with ano
ther collection.
Create a new entry
in the collection. T
he new entry's URL
is assigned automa
tically and is usuall
y returned by the
operation.
Delete the entire c
ollection.
Element URI, such
as http://example.
com/resources/ite
m17
Retrieve a represen
tation of the addre
ssed member of th
e collection, expres
sed in an appropri
ate Internet media
type.
Replace the addres
sed member of the
collection, or if it d
oesn't exist, create
it.
Treat the addresse
d member as a col
lection in its own ri
ght and create a n
ew entry in it.
Delete the address
ed member of the
collection.