狠狠撸

狠狠撸Share a Scribd company logo
The introduction of RESTful
Uniform Resource Locator(URL)
? Commonly informally termed a web address is a reference to a web
resource that specifies its location on a computer network and a
mechanism for retrieving the resource.
? Format
[ scheme://user:password@host:port/path?query#fragment ]
1. scheme: The canonical form is lowercase and documents that specify
schemes must do so with lowercase letters. It is followed by a colon (:).
Examples of popular schemes include http, ftp, mailto, file, data etc.
2. Authority part:
a. An optional authentication section of a user and password,
separated by a colon, followed by an at symbol (@).
b. A "host", consisting of either a registered name or an IP
address. IPv4addresses must be in dot-decimal notation,
and IPv6 addresses must be enclosed in brackets ([ ]).
c. An optional port number, separated from the hostname by a
colon.
Uniform Resource Locator(URL)
? Format
3. A path, which contains data, usually organized in hierarchical
form, that appears as a sequence of segments separated by
slashes. Such a sequence may resemble or map exactly to a file
system path or web resource(REST).
4. An optional query, separated from the preceding part by a
question mark (?), containing a query string of non-
hierarchical
data. Its syntax is not well defined, but by convention is most
often a sequence of attribute–value pairs separated by a
ampersand (&) or semicolon (;).
Uniform Resource Locator(URL)
? Format
5. An optional fragment, separated from the preceding
part by a hash (#). The fragment contains a fragment
identifier providing direction to a secondary resource. It is
often an ID attribute of a specific element, and web
browsers will scroll this element into view.
Hypertext Transfer Protocol(HTTP)
? HTTP functions as a request–response protocol in
the client–server computing model. A web browser, for
example, may be the client
and an application running on a computer a website may
be the server. The client submits an
HTTP request message to the server. The server, which
provides resources such as HTML files and other content
as JSON/XML/SOAP, or performs other functions on
behalf of the client, returns a response message to the
client. The response contains completion status
information about the request and may also contain
requested content in its message body.
HTTP Request Data Block
HTTP Request Data
? Verb- Indicate HTTP methods such as
1. POST(Create) – This method requests that the server accept the entity enclosed
in the request body as a new subordinate of the web resource identified by the
URI.
2. GET(Read) – The method requests a representation of the specified
resource. Requests using GET should only retrieve data and should have no
other effect.
3. HEAD(read) – This is useful for retrieving meta-information written in
response headers, without having response body.
4. PUT(Update) – This method requests that a web server accept and store the data
enclosed in the request body. If the URI refers to an already existing resource, it is
modified; if the URI does not point to an existing resource, then the server can
create the resource with that URI.
5. PATCH(Update) – This method applies partial modifications to a resource.
6. DELET(Delete) – This method deletes the specified resource.
HTTP Request Data
? URI- Contains the URI, Uniform Resource Identifier
to identify the resource on server
? HTTP Version- Indicate HTTP version, for example
HTTP v1.1 .
? Request Header- Contains metadata for the HTTP
Request message as key-value pairs. For example,
client ( or browser) type, format supported by client,
format of message body, cache settings etc.
? Request Body- Message content or Resource
representation.
HTTP Response Data Block
HTTP Response Data
? Status/Response Code- Indicate Server status for the
requested resource. For example 404 means resource
not found and 200 means response is ok.
? HTTP Version- Indicate HTTP version, for example
HTTP v1.1 .
? Response Header- Contains metadata for the HTTP
Response message as key-value pairs. For example,
content length, content type, response date, server
type etc.
? Response Body- Response message content or
Resource representation.
HTTPS
HTTPS
Method Table
Representation State Transfer(REST)
? Nouns – An URL
? Content Types – JSON, XML, CSS
? Verbs – GET, POST, PUT, DELETE
? Client(browser) deliver a Verb with a
uniform Noun(URL) to a
server(Apache httpd) , and server
implement the Verb in a specified
web resource and response the
results(Content-Types)
represented via browser UI of being
recognizable by humans intuitively.
REST Architectural Elements
? Data Element
a. Resource – The intended conceptual target of a hypertext reference
b. Resource Identifier – HTTP URL
c. Representation – HTTP Content-Type
? Connector
a. Client – HTTP client library
b. Server – Apache API
c. Cache – Browser Cache, Network Cache
d. Resolver – DNS lookup library
e. Tunnel – SSL
? Components
a. User Agent – Browser
b. Origin Server – Apache httpd, M$ II$.
c. Gateway – CGI
d. Proxy – Proxy
REST Constraints? Client – Server: Clients(request) and servers(response) communicate over
an intermediate(computer network on separate hardware), but both client
and server may reside in the same system. A server host runs one or more
server programs which share their resources with clients.
? Stateless: Stateless means each request from clients as an independent
transaction that is unrelated to any previous request so that the
communication consists of independent pairs of request and response and
there are no client context being stored on the server between requests.
A stateless protocol does not require the server to retain session
information or status about each communications partner for the duration
of multiple requests.
? Cacheable: A temporary storage of web documents, such as HTML pages and
images, to reduce bandwidth usage. Clients can cache responses. Responses
must define themselves as cacheable to prevent clients from reusing stale or
inappropriate data in response to further requests ; requests may be satisfied
from the cache.
? Layered System: It is a system in which components are grouped, layered, in
a hierarchical arrangement, such that lower layers provide functions and services
that support the functions and services of higher layers. A client cannot
ordinarily tell whether it is connected directly to the end server, or to an
intermediary along the way.
REST Constraints
? Uniform Interface: The four constraints for this uniform interface are
a. Identification of resources: Individual resources are identified in
requests(nouns), Ex: URL
b. Manipulation of resources through representations: a client holds a
representation of a resource, including any metadata attached, it has enough
information to access/process the resource.
Ex: POST , GET, PUT, DELETE
c. Self-descriptive Messages: Each message includes enough information to describe
how to process the message.
Ex. The Content-Type
d. Hypermedia as the engine of application state: A REST client needs no prior
knowledge about how to interact with any particular application or server beyond a
generic understanding of hypermedia. Clients and servers interact through a
fixed interface shared through documentation or an interface description
language (IDL) to loosing coupled for security.
Ex: JSON
? Code on demand (optional) : Servers can temporarily extend or
customize the functionality of a client by the transfer of executable code.
Ex: Python / JavaScript
RESTful System
Connector
Client
Resource
An URL
+
HTML/JSON/X
ML/CSS/IMG
Componen
t
Gateway
Connector
Server
Verb
GET
Connector
Browser
Cache
Tunnel(SSL)
Connector
Network
Cache
Nouns
https://www.example.co
m
Resource Identifier
Content Type
Content-Type:
text/html
Content-Length: 123
{ Data }
Representation
Componen
t
Browser
s
Connector
DNS
Componen
t
httpd
HTTP Is a RESTful System
JavaScript Object Notation(JSON )
? JSON is a lightweight data-interchange format. It is easy for
humans to read and write. It is easy for machines to parse
and generate. It is based on a subset of the JavaScript
Programming Language.
JSON Forms - Object
? An object is an unordered set of name/value pairs. An
object begins with { (left brace) and ends with } (right
brace). Each name is followed by : (colon) and the
name/value pairs are separated by , .
JSON Forms - Array
? An array is an ordered collection of values. An array
begins with [ (left bracket) and ends with ] (right
bracket). Values are separated by ,.
JSON Forms - Value
? A value can be a string in double quotes, or a number,
or true or false or null, or an object or an array. These
structures can be nested.
JSON Forms - String? A string is a sequence of zero or more Unicode characters, wrapped in
double quotes, using backslash escapes. A character is represented as a
single character string. A string is very much like a C or Java string.
JSON Forms - Number
? A number is very much like a C or Java number, except
that the octal and hexadecimal formats are not used.
Web Communication Flow Chart

More Related Content

The introduction of RESTful

  • 2. Uniform Resource Locator(URL) ? Commonly informally termed a web address is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving the resource. ? Format [ scheme://user:password@host:port/path?query#fragment ] 1. scheme: The canonical form is lowercase and documents that specify schemes must do so with lowercase letters. It is followed by a colon (:). Examples of popular schemes include http, ftp, mailto, file, data etc. 2. Authority part: a. An optional authentication section of a user and password, separated by a colon, followed by an at symbol (@). b. A "host", consisting of either a registered name or an IP address. IPv4addresses must be in dot-decimal notation, and IPv6 addresses must be enclosed in brackets ([ ]). c. An optional port number, separated from the hostname by a colon.
  • 3. Uniform Resource Locator(URL) ? Format 3. A path, which contains data, usually organized in hierarchical form, that appears as a sequence of segments separated by slashes. Such a sequence may resemble or map exactly to a file system path or web resource(REST). 4. An optional query, separated from the preceding part by a question mark (?), containing a query string of non- hierarchical data. Its syntax is not well defined, but by convention is most often a sequence of attribute–value pairs separated by a ampersand (&) or semicolon (;).
  • 4. Uniform Resource Locator(URL) ? Format 5. An optional fragment, separated from the preceding part by a hash (#). The fragment contains a fragment identifier providing direction to a secondary resource. It is often an ID attribute of a specific element, and web browsers will scroll this element into view.
  • 5. Hypertext Transfer Protocol(HTTP) ? HTTP functions as a request–response protocol in the client–server computing model. A web browser, for example, may be the client and an application running on a computer a website may be the server. The client submits an HTTP request message to the server. The server, which provides resources such as HTML files and other content as JSON/XML/SOAP, or performs other functions on behalf of the client, returns a response message to the client. The response contains completion status information about the request and may also contain requested content in its message body.
  • 7. HTTP Request Data ? Verb- Indicate HTTP methods such as 1. POST(Create) – This method requests that the server accept the entity enclosed in the request body as a new subordinate of the web resource identified by the URI. 2. GET(Read) – The method requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect. 3. HEAD(read) – This is useful for retrieving meta-information written in response headers, without having response body. 4. PUT(Update) – This method requests that a web server accept and store the data enclosed in the request body. If the URI refers to an already existing resource, it is modified; if the URI does not point to an existing resource, then the server can create the resource with that URI. 5. PATCH(Update) – This method applies partial modifications to a resource. 6. DELET(Delete) – This method deletes the specified resource.
  • 8. HTTP Request Data ? URI- Contains the URI, Uniform Resource Identifier to identify the resource on server ? HTTP Version- Indicate HTTP version, for example HTTP v1.1 . ? Request Header- Contains metadata for the HTTP Request message as key-value pairs. For example, client ( or browser) type, format supported by client, format of message body, cache settings etc. ? Request Body- Message content or Resource representation.
  • 10. HTTP Response Data ? Status/Response Code- Indicate Server status for the requested resource. For example 404 means resource not found and 200 means response is ok. ? HTTP Version- Indicate HTTP version, for example HTTP v1.1 . ? Response Header- Contains metadata for the HTTP Response message as key-value pairs. For example, content length, content type, response date, server type etc. ? Response Body- Response message content or Resource representation.
  • 11. HTTPS
  • 12. HTTPS
  • 14. Representation State Transfer(REST) ? Nouns – An URL ? Content Types – JSON, XML, CSS ? Verbs – GET, POST, PUT, DELETE ? Client(browser) deliver a Verb with a uniform Noun(URL) to a server(Apache httpd) , and server implement the Verb in a specified web resource and response the results(Content-Types) represented via browser UI of being recognizable by humans intuitively.
  • 15. REST Architectural Elements ? Data Element a. Resource – The intended conceptual target of a hypertext reference b. Resource Identifier – HTTP URL c. Representation – HTTP Content-Type ? Connector a. Client – HTTP client library b. Server – Apache API c. Cache – Browser Cache, Network Cache d. Resolver – DNS lookup library e. Tunnel – SSL ? Components a. User Agent – Browser b. Origin Server – Apache httpd, M$ II$. c. Gateway – CGI d. Proxy – Proxy
  • 16. REST Constraints? Client – Server: Clients(request) and servers(response) communicate over an intermediate(computer network on separate hardware), but both client and server may reside in the same system. A server host runs one or more server programs which share their resources with clients. ? Stateless: Stateless means each request from clients as an independent transaction that is unrelated to any previous request so that the communication consists of independent pairs of request and response and there are no client context being stored on the server between requests. A stateless protocol does not require the server to retain session information or status about each communications partner for the duration of multiple requests. ? Cacheable: A temporary storage of web documents, such as HTML pages and images, to reduce bandwidth usage. Clients can cache responses. Responses must define themselves as cacheable to prevent clients from reusing stale or inappropriate data in response to further requests ; requests may be satisfied from the cache. ? Layered System: It is a system in which components are grouped, layered, in a hierarchical arrangement, such that lower layers provide functions and services that support the functions and services of higher layers. A client cannot ordinarily tell whether it is connected directly to the end server, or to an intermediary along the way.
  • 17. REST Constraints ? Uniform Interface: The four constraints for this uniform interface are a. Identification of resources: Individual resources are identified in requests(nouns), Ex: URL b. Manipulation of resources through representations: a client holds a representation of a resource, including any metadata attached, it has enough information to access/process the resource. Ex: POST , GET, PUT, DELETE c. Self-descriptive Messages: Each message includes enough information to describe how to process the message. Ex. The Content-Type d. Hypermedia as the engine of application state: A REST client needs no prior knowledge about how to interact with any particular application or server beyond a generic understanding of hypermedia. Clients and servers interact through a fixed interface shared through documentation or an interface description language (IDL) to loosing coupled for security. Ex: JSON ? Code on demand (optional) : Servers can temporarily extend or customize the functionality of a client by the transfer of executable code. Ex: Python / JavaScript
  • 18. RESTful System Connector Client Resource An URL + HTML/JSON/X ML/CSS/IMG Componen t Gateway Connector Server Verb GET Connector Browser Cache Tunnel(SSL) Connector Network Cache Nouns https://www.example.co m Resource Identifier Content Type Content-Type: text/html Content-Length: 123 { Data } Representation Componen t Browser s Connector DNS Componen t httpd
  • 19. HTTP Is a RESTful System
  • 20. JavaScript Object Notation(JSON ) ? JSON is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language.
  • 21. JSON Forms - Object ? An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , .
  • 22. JSON Forms - Array ? An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by ,.
  • 23. JSON Forms - Value ? A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.
  • 24. JSON Forms - String? A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.
  • 25. JSON Forms - Number ? A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used.