web technologies - alexandru ioan cuza universitybusaco/teach/courses/web/presentations/...http/1.1...
TRANSCRIPT
![Page 1: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/1.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/Web Technologies
Web programming (I)
⥁HTTP protocol
cookies & sessions
![Page 2: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/2.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
“There are 2 ways to write error-free programs; only the third one works.”
Alan Perlis
![Page 3: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/3.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
What the Web means?
![Page 4: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/4.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
World Wide Web
an information space containing elements (things) of interest, called resources,
denoted by global identifiers – URI/IRI
details at www.w3.org/TR/webarch/W3C Recommendation (2004)
![Page 5: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/5.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
Web resources
Aspects of interest
identification
interaction
representation by using data formats
![Page 6: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/6.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
Web resources
Aspects of interest
identification
interaction
representation by using data formats
URI/IRIprotocol:
HTTP
markup language(s)
![Page 7: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/7.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
How about the interaction between client(s) and Web server(s)?
![Page 8: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/8.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP
HyperText Transfer Protocol
based on TCP/IP
![Page 9: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/9.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP
situated on the application layer
access control to the data transmission medium (MAC – Medium Access Control)
network interconnection + data routing(IP – Internet Protocol)
reliable transport via sockets(TCP – Transmission Control Protocol)
hypertext/hypermedia transfer(HTTP – HyperText Transfer Protocol)
![Page 10: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/10.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP
HyperText Transfer Protocol
a reliable request/response protocol
standard access port: 80
![Page 11: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/11.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP
HTTP/1.1
Internet standard: RFC 2616 (1999)
from 2014, defined by RFC 7230—7235
www.w3.org/Protocols/
http://devdocs.io/http/
![Page 12: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/12.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP
HTTP/2.0
RFC 7540 (2015)
focused on performance
http://royal.pingdom.com/2015/06/11/http2-new-protocol/
http://http2.github.io/
![Page 13: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/13.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: architecture
Web Server
daemon – “attendant spirit”
Web Client
browser, Web bot (crawler), multimedia player,…
![Page 14: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/14.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: architecture
Web ServerApache, Internet Information Services, Lighttpd, Nginx,…
Web ClientMosaicNetscapeMozillaFirefox,
Internet Explorer, Chromium, wget, iTunes, Echofon, etc.
details in “Web browser architecture” presentation:http://profs.info.uaic.ro/~busaco/teach/courses/cliw/web-film.html#week2
![Page 15: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/15.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP
Request and responseaccessing – possibly, changing – a resource
representation by using its URI
Web Server
Web Client
request
response
![Page 16: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/16.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
Message
base unit of the HTTP communication(request or response)
![Page 17: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/17.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
Intermediary
proxygatewaytunnel
![Page 18: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/18.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
Proxylocated in the client/server proximity
having the role of both server and client
Web Server
Web Client p
rox
y
![Page 19: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/19.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
Proxy
forward proxyintermediary for a group of clients
acts on behalf of clients
reverse proxyintermediary for a group of servers
advanced
![Page 20: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/20.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
Gatewayintermediary hiding the target (origin) server
the client has no knowledge about it
Web Gate-way
Web Client
Web Server
Web Server
![Page 21: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/21.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
Gateway
can assure: traffic distribution across servers – load balancing
short-term data storage – cachingmessage or request translation (e.g., HTTPSHTTP)
other negotiation operations – role of mediator/broker
open source solutions: HAProxy, Squid, Varnishcloud-based: Amazon ELB (Elastic Load Balancing)
advanced
![Page 22: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/22.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
Tunnel
retransmits – usually, encrypted – HTTP messages
![Page 23: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/23.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
Tunnel
retransmits – usually, encrypted – HTTP messages
context: HTTPS protocol – to assure a “secure” HTTP communication via TLS (Transport Layer Security)
authentication based on digital certificates+ bidirectional data encryption
![Page 24: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/24.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
details about a HTTPS
connection
advanced
![Page 25: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/25.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
Cache
local storage area – in memory, on a disc –for the messages (data)
server- and/or client-side
![Page 26: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/26.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: concepts
Cache
local storage area – in memory, on a disc –for the messages (data)
future requests for that data can be served faster
context: Web application performance
![Page 27: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/27.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: messages
HTTP message = header + body
![Page 28: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/28.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: messages
Header
includes a set of fields
field-name ":" [ field-value ] CRLF
CR = Carriage Return \r – code 13LF = Line Feed \n – code 10
![Page 29: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/29.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: messages
HTTP request
Method Request-URI ProtocolVersion CRLF
[ Message-header ] [ CRLF MIME-data ]
GET /~busaco/teach/courses/web/ HTTP/1.1 CRLF
Host: profs.info.uaic.ro
![Page 30: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/30.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: messages
HTTP response
HTTP-version Digit Digit Digit Reason
CRLF Content
HTTP/1.1 200 OK CRLF …
![Page 31: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/31.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: methods
GET
request – performed by a client – to access a resource representation
HTML document, CSS stylesheet, image in PNG format, vector illustration as SVG,
JavaScript program, Atom or RSS (XML) news feed,PDF presentation, JSON data,…
![Page 32: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/32.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: methods
HEAD
similar to GETusually, offers only meta-data
e.g., MIME type of a resource, last update,…
![Page 33: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/33.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: methods
PUT
updates a resource representation or, possibly, creates a resource on the Web server
![Page 34: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/34.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: methods
POST
creates a resource, usually sending entities (data, actions) to the server
e.g., data entered into a Web form’ fields
![Page 35: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/35.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: methods
DELETE
erases a resource – its representation –from the server
![Page 36: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/36.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: methods
Remark
traditionally, the Web browser only permits the use of GET and POST methods
![Page 37: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/37.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: methods
A method is considered safeif it does not modify the server state
i.e. no side-effect actions are performed on the server
GET and HEAD are safe
POST, PUT and DELETE are not safe
advanced
![Page 38: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/38.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: methods
A method is considered idempotent when it can be called many times without different outcomes,returning the same response (representation)
GET, HEAD, PUT and DELETE are idempotent
POST is not idempotent
advanced
![Page 39: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/39.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: resource representations
Character set encodings
ISO-8859-1ISO-8859-2
KOI8-RISO-2022-JP
UTF-8UTF-16 Little Endian
…
![Page 40: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/40.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: resource representations
Message (content) encodings
compression, identity and/or integrity
in most cases: gzip
![Page 41: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/41.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: resource representations
Representation formats
textHTML, CSS, plain text, JavaScript code, XML document
or
binaryimage (JPEG, PNG), PDF document, multimedia resource
![Page 42: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/42.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: resource representations
Types of the resource content
media types
![Page 43: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/43.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/HTTP: header fields (attributes)
Content-Type
permits the transfer of any kind of data
Content-Type: type/subtype
![Page 44: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/44.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/HTTP: header fields (attributes)
Content-Type
specified by Media Types – MIME(Multipurpose Internet Mail Extensions)
denotes a set of primary content types+ additional sub-types
initially, used in the e-mail context
![Page 45: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/45.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: header fields (attributes)
Primary types
text indicates textual formats
text/plain – unformatted texttext/html – HTML document
text/css – CSS (Cascading Style Sheets) resource
![Page 46: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/46.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: header fields (attributes)
Primary types
image specifies graphical formats
image/gif – GIF (Graphics Interchange Format) imagesimage/jpeg – JPEG (Joint Picture Experts Group) photosimage/png – PNG (Portable Network Graphics) pictures
![Page 47: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/47.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: header fields (attributes)
Primary types
audio denotes audio content
audio/mpeg – resource encoded in MP3 formatspecification for audio data according to
the MPEG (Motion Picture Experts Group) standard
audio/ac3 – compressed audio resourceconforming to AC-3 standard
![Page 48: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/48.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: header fields (attributes)
Primary types
video defines video content: animations, films
video/h264 – resource in H.264 format
video/ogg – content encoded in OGG open format
![Page 49: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/49.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: header fields (attributes)
Primary types
application signifies formats that can be processed by applications on the client-side
application/javascript – JavaScript programapplication/json – JSON (JavaScript Object Notation) data
application/octet-stream – stream of arbitrary bytes
![Page 50: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/50.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: header fields (attributes)
Primary types
multipart used to transfer composed data
multipart/mixed – mixed contentmultipart/alternative – alternative contents
e.g., different qualities of multimedia streams
![Page 51: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/51.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/N. Freed et al., Media Types (February 2017)
http://www.iana.org/assignments/media-types/media-types.xhtml
calendar+json application/calendar+json Calendar in JSON format
csv text/csv CSV data
opus audio/opus Opus audio resource
msword application/msword Word (MS Office) document
tiff image/tiff Image in TIFF format
vnd.rar application/vnd.rar RAR archive
zip application/zip ZIP archive
![Page 52: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/52.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/HTTP: header fields (attributes)
Location
Location ":" "http(s)://" authority [ ":" port ] [ abs_path ]
redirects the client to the other resource representation(HTTP redirect)
Location: http://somewhere.info:8080/moved.html
![Page 53: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/53.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/HTTP: header fields (attributes)
Referer
denotes the URI of a Web resource that refers to the current resource
used to know the URI source of the requests to a given document (i.e. back-links)
for analytics, logging, caching,…
![Page 54: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/54.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/HTTP: header fields (attributes)
Host
specifies the target address – IP or symbolic domain – of the machine supposed to provide
a requested resource
![Page 55: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/55.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/HTTP: header fields (attributes)
Other existing fields concern the following:
accepted content (content negotiation) – e.g., Accept
authentication & authorization – WWW-Authenticate Authorization
conditional access to resources – If-Match, If-Modified-Since,…caching policies – Cache-Control, Expires, ETag, etc.proxy – Proxy-Authenticate, Proxy-Authorization, Via
…and others
www.iana.org/assignments/message-headers/message-headers.xhtml
advanced
![Page 56: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/56.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: status
Informational (1xx)
100 Continue, 101 Switching Protocols
switching protocols: from HTTP to WebSocket (RFC 6455)
![Page 57: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/57.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: status
Success (2xx)
200 Ok, 201 Created, 202 Accepted,204 No Content, 206 Partial Content
OPTIONS – method to determine server capabilities or requirements for a resource
![Page 58: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/58.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: status
Redirection (3xx)
300 Multiple Choices, 301 Moved Permanently, 302 Found,303 See Other, 304 Not Modified, 305 Use Proxy
![Page 59: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/59.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: status
Client Error (4xx)
400 Bad Request, 401 Unauthorized, 403 Forbidden,
405 Method Not Allowed, 408 Request Timeout,
414 Request-URI Too Long
![Page 60: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/60.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: status
Server Error (5xx)
500 Internal Server Error, 502 Bad Gateway,
503 Service Unavailable, 504 Gateway Timeout
![Page 61: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/61.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: logging
Requests sent to a Web server are logged
Common Log Format
standardized text file format
for Apache HTTP Server: mod_log_config module
![Page 62: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/62.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
c12.uaic.ro - msi2013 [13/Feb/2014:14:53:14 +0200] "GET /~vidrascu/MasterSI2/note/Restanta.pdf HTTP/1.1" 206 25227 "http://profs.info.uaic.ro/~vidrascu/MasterSI2/index.html" "...Firefox/27.0"
82-137-8-231.rdsnet.ro - - [13/Feb/2014:15:38:23 +0200] "POST /~computernetworks/login.php HTTP/1.1" 302 1115 "http://profs.info.uaic.ro/~computernetworks/login.php" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0"
ec2-23-21-0-202.compute-1.amazonaws.com - - [13/Feb/2014:15:48:29 +0200] "GET /~busaco/teach/courses/web/presentations/web01ArhitecturaWeb.pdf HTTP/1.1" 200 2081804 "-" "HTTP_Request2/2.2.0 (http://pear.php.net/package/http_request2)..."
199.16.156.126 - - [13/Feb/2014:15:58:58 +0200] "GET /robots.txt HTTP/1.1" 404 182 "-" "Twitterbot/1.0"
psihologie-c-113.psih.uaic.ro - - [13/Feb/2014:16:03:04 +0200] "GET /~busaco/ HTTP/1.1" 200 1942 "-" "Mozilla/5.0 (X11; Linux x86_64; ...) Firefox/27.0"
psihologie-c-113.psih.uaic.ro - - [13/Feb/2014:16:03:04 +0200] "GET /~busaco/csb.css HTTP/1.1" 200 852 "http://profs.info.uaic.ro/~busaco/" "Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0"
proxy-220-255-2-224.singnet.com.sg - - [13/Feb/2014:16:23:23 +0200] "GET /favicon.ico HTTP/1.1" 200 1406 "-" "Dalvik/1.6.0 (Linux; U; Android 4.0.4; ...)"
c2.uaic.ro - - [13/Feb/2014:16:33:43 +0200] "GET /~busaco/teach/courses/web/ HTTP/1.1" 304 - "-" "... Chrome/32.0.1700.107..."
220.181.51.219 - - [13/Feb/2014:19:20:20 +0200] "HEAD /%7Ebusaco/music/09.Sabin%20Buraga%20-...mp3 HTTP/1.0" 200 - "-" "NSPlayer/10.0.0.4072 WMFSDK/10.0"
![Page 63: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/63.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
GET /~busaco/teach/courses/web/web-film.html HTTP/1.1
Host: profs.info.uaic.ro
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_1_1
like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko)
Version/10.0 Mobile/14B100 Safari/602.1
Accept: text/html,application/xhtml+xml;q=0.9,*/*;q=0.8
Accept-Language: en-us, en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Referer: http://profs.info.uaic.ro/~busaco/teach/courses/web/
HTTP: request – example
![Page 64: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/64.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP/1.1 200 OK
Date: Mon, 27 Feb 2017 15:18:01 GMT
Server: Apache
Last-Modified: Mon, 27 Feb 2017 07:46:02 GMT
Content-Encoding: gzip
Content-Length: 11064
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
lang="ro" xml:lang="ro">
…
</html>
con
ten
t
header fields(meta-data)
HTTP: response – example
![Page 65: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/65.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
advanced
online inspection of HTTP messageswith www.hurl.it
![Page 66: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/66.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
avansat
X- fields are not standardized
expires in the past(not stored in cache)
actual content(Atom feed)
processed by client
![Page 67: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/67.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: APIs (libraries)
cURL + libcurl
(C, Java, Haskell, .NET, PHP, Ruby,…) – http://curl.haxx.se/
Apache HttpComponents (Java) – http://hc.apache.org/
httplib (Python 2) + http.client (Python 3)
neon (C library): http://www.webdav.org/neon/
WinHTTP
(Windows specific: C/C++) – http://tinyurl.com/6eemqqc
advanced
![Page 68: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/68.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: client-side tools
Google Chrome Developer Toolshttps://developers.google.com/web/tools/chrome-devtools/
Firefox Developer Toolshttps://developer.mozilla.org/docs/Tools
Fiddler – a free Web debugging proxywww.telerik.com/fiddler
avansat
![Page 69: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/69.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
(instead of) break
![Page 70: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/70.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
How about the Web server architecture?
![Page 71: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/71.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: Web server
Fulfills multiple requests from the clients respecting the HTTP protocol
![Page 72: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/72.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: Web server
Fulfills multiple requests from the clients respecting the HTTP protocol
each request is considered independent from others, although it was issued by the same Web clientconnection state is not kept – stateless
![Page 73: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/73.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: Web server
Traditionally, the Web server implementation
is either pre-forked or pre-threaded
on initialization, a number of child processes or threads are created, each process/thread interacting to
a distinct client
advanced
![Page 74: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/74.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: server Web
advanced
http://strongloop.com/strongblog/node-js-is-faster-than-java/
![Page 75: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/75.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: Web server
Server behavior can be controlled by various configuration parameters (directives)
advanced
![Page 76: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/76.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: Web server
Case study: Apache HTTP Server configuration (from April 1996, the most popular Web server)
http://httpd.apache.org/
global configuration: httpd.conf file6 httpd instances are created by default
a user specific configuration (per directory/URI) is defined via .htaccess – see also https://github.com/phanan/htaccess
advanced
![Page 77: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/77.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: Web server
Case study: Apache HTTP Server configuration
possibility to define virtual hosts – virtual hosting:same server can host (run) multiple Web sites,
with different symbolic domain names
advanced
![Page 78: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/78.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP request
post-read-request
IRI translation
headerparsing
accesscontrol
authen-tication
authori-zation
media typechecker
response
log
cleanup
datato theclient
advanced
Apache server: request processing
loop
![Page 79: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/79.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: Web server
Usually, the Web server architecture is modular
kernel (core) +
modules implementing specific functionalities
advanced
![Page 80: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/80.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: Web server
Usually, the Web server architecture is modular
kernel (core) +
modules implementing specific functionalities
provides a C language-based API (Application Programming Interface) to create modules
advanced
![Page 81: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/81.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: Web server
Usually, the Web server architecture is modular
kernel (core) +
modules implementing specific functionalities
examples (Apache): mod_auth_basic, mod_cache, mod_deflate, mod_include, mod_proxy, mod_session, mod_ssl
advanced
![Page 82: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/82.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP: Web server
Other approach: asynchronous (non-blocked) single threaded strategies
reference examples: nginx
Node.js
avansat
![Page 83: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/83.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
How can we develop the back-end of Web applications?
![Page 84: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/84.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
necessity
Dynamic generation – on the server –of representations of resources
requested by clients
![Page 85: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/85.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
necessity
Dynamic generation – on the server –of representations of resources
requested by clients
![Page 86: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/86.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
solutions
CGI – Common Gateway Interface
Web application servers
Web frameworks
![Page 87: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/87.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
solution: cgi
Language-independent programming interfacefacilitating the interaction between clients and
programs invoked on the Web server
de facto standard
RFC 3875http://www.w3.org/CGI/
![Page 88: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/88.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi
A CGI program (script) is invoked on server
directly
i.e., retrieving data from a Web form after the submit button is pressed
![Page 89: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/89.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi
A CGI program (script) is invoked on server
indirectly
example: at each visit a new ad (e.g., banner) is generated
![Page 90: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/90.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi
CGI scripts can be written in any language available on the server
interpreted languagesbash, Perl – e.g., Perl::CGI module –, Python, Ruby,...
compiled languagesC, C++ etc.
![Page 91: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/91.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: programming
Each CGI program will write data – the representation of a Web resource –
at standard output (stdout)
![Page 92: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/92.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: programming
To denote the type of generated representation, HTTP headers are used – MIME (Media Types)
example: Content-type: text/html
![Page 93: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/93.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: programming
Interaction between the client and Web server
Web Server
Web Client
request
response
script
invo-cation
![Page 94: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/94.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: variables
A CGI script has access to environment variables
associated to the request sent to the CGI program:
REQUEST_METHOD – HTTP method (GET, POST,…)QUERY_STRING – data transmitted to the clientREMOTE_HOST, REMOTE_ADDR – client address
CONTENT_TYPE – content type as MIME (Media Type)CONTENT_LENGTH – content length in bytes
![Page 95: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/95.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: variables
Additional variablesusually, generated by the Web server:
HTTP_ACCEPT – MIME types accepted by client (browser)HTTP_COOKIE – data about cookiesHTTP_HOST – information regarding the host (client)HTTP_USER_AGENT – information about the client
…and others
![Page 96: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/96.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
a result received by Web client after the invocation via GET on Web server
of variabile.cgi script(having read & execution rights)
#!/bin/bash# Setting the content typeecho "Content-type: text/plain"; echo
# Executing 'set' command in Linux# to show environment variablesset
![Page 97: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/97.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
/* hello.c
(compile with gcc hello.c –o hello.cgi) */
#include <stdio.h>
int main() {
int msgs; /* number of messages */
printf ("Content-type: text/html\n\n");
for (msgs = 0; msgs < 10; msgs++) {
printf ("<p>Hello, world!</p>");
}
return 0;
}
#!/usr/bin/python
# hello.py.cgi
print "Content-type: text/html\n"
for messages in range (0, 10):
print "<p>Hello, world!</p>"
#!/bin/bash
# hello.sh.cgi
echo "Content-type: text/html"
echo
MESSAGES=0
while [ $MESSAGES -lt 10 ]
do
echo "<p>Hello, world!</p>"
let MESSAGES=MESSAGES+1
done
CGI programs written in C, bash, Python generating the same HTML content
advanced
![Page 98: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/98.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: invocare
experimenting other MIME types, the browser displays the following:
Content-type: text/plain Content-type: text/xml
advanced
![Page 99: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/99.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: invocation
<form action="http://profs.info.uaic.ro/~.../get-max.cgi"method="GET">
<p>Enter two numbers :<input type="text" name="no1" /> <input type="text" name="no2" /> </p><input type="submit" value="Compute maximum" />
</form>
invocation from an interactive Web formin this case, using the GET method
![Page 100: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/100.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/cgi: invocation
special URL in GET case
![Page 101: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/101.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: invocation
For each form field, a field_name=value pair – delimited by & – is generated and added to the URL
of the CGI script to be invoked on server
http://profs.info.uaic.ro/~busaco/cgi/get-max.cgi?no1=7&no2=4
![Page 102: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/102.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: invocation
Real-life examples:
http://usabilitygeek.com/?s=web+design
https://www.youtube.com/watch?v=hEzmy93zr0Y#t=540
https://twitter.com/search?q=web%20development&src=typd
https://developer.mozilla.org/search?q=ajax&topic=apps
this URL is encoded – URL encodingsee first lecture
![Page 103: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/103.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: invocation
The server will invoke a CGI script passing the dataat standard input (stdin)
orvia environment variables
![Page 104: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/104.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: invocation
Data processing when GET method is used
data available in QUERY_STRING variable
![Page 105: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/105.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: invocation
Data processing when POST method is used
data read from stdin, the length in bytes being specified by CONTENT_LENGTH variable
![Page 106: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/106.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: invocation
Data processing – GET and/or POST
in case of application servers or frameworks, data is encapsulated into specific structures/types
ASP.NET (C#) – HttpRequest classPHP – associative arrays: $_GET[] $_POST[] $_REQUEST[]
Play (Java, Scala) – play.api.mvc.Request
Node.js (JavaScript) – http.ClientRequest
advanced
![Page 107: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/107.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
GET vs. POST
GET method is used to generate the representations of the requested resources
e.g., HTML documents, JPEG images, Atom/RSS news feeds, ZIP archives, etc.
the server state should not be modified
![Page 108: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/108.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
GET vs. POST
GET method is used to generate the representations of the requested resources
obtaining data with GET, the user can set a bookmark for further accesses to the Web resource
(by using the URL of the generated representation)
e.g., https://duckduckgo.com/?q=web+programming&ia=videos
![Page 109: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/109.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
GET vs. POST
POST method is used when the data transmitted to the server is large (e.g., upload of file content)
or sensitive – typically, passwords
![Page 110: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/110.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
GET vs. POST
POST method is used when the data transmitted to the server is large (e.g., upload of file content)
or sensitive – typically, passwords
plus, when the script invocation can produce a state change on the server:
adding a record, altering a file,...
![Page 111: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/111.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: support
Web server should support CGI script invocation
example: Apache HTTP Server provides the mod_cgi module
advanced
![Page 112: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/112.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: ssi
CGI scripts could be directly invoked from a HTML document via SSI (Server Side Includes)
http://www.ssi-developer.net/ssi/
Apache: http://httpd.apache.org/docs/trunk/howto/ssi.html
Nginx: http://nginx.org/en/docs/http/ngx_http_ssi_module.html
advanced
![Page 113: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/113.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cgi: fastcgi
FastCGIan alternative to CGI focused on performance
implementations:Apache – https://httpd.apache.org/mod_fcgid/
Nginx – nginx.org/en/docs/http/ngx_http_fastcgi_module.html
advanced
![Page 114: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/114.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
How about a manner to – temporarily – store on front-end (browser) the data transmitted
by the back-end of Web application?
![Page 115: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/115.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
A script running on a Web server can put data on the client-computer via the user’s Web browser
subsequently, the navigator will return that data to the same script available on the same server
![Page 116: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/116.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
A (quasi-)persistent way to store data on the machine of a Web client in order to be
further accessed by a program running on a server
![Page 117: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/117.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: usages
Storing user preferences
typical examples: options regarding interaction – visual theme
(e.g., chromatics), lingual preferences, etc.geographical location, interests on shopping
…
![Page 118: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/118.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: usages
Automatic form completion
using already entered values for certain fields
![Page 119: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/119.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: usages
Monitoring the access to a Web resource
aspect of interest:Web analytics
collecting information about clients(hardware platform, browser, screen resolution, etc.)
![Page 120: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/120.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: usages
Monitoring the access to a Web resource
aspect of interest:user tracking
monitoring the user behaviorDo Not Track initiative – http://donottrack.us/
![Page 121: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/121.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: usages
Storing the authentication info
e.g., keeping data about the user account in the e-commerce context
![Page 122: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/122.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: usages
Transaction status
e.g., current state of the virtual shopping cart provided by an e-shop application
![Page 123: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/123.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: usages
Web session management
![Page 124: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/124.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: types
Persistent cookies
not destroyed when Web browser closes
kept into a file – client-side
time-to-live set by the cookie creator
![Page 125: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/125.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: types
Non-persistent (volatile) cookies
disappear when the browser is closed
![Page 126: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/126.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
A cookie can be considered as a variable
its value is transferred via HTTP between the Web server (back-end application)
and the client (browser)
![Page 127: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/127.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
A cookie can be considered as a variable
name=value
the value is an URL encoded string
![Page 128: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/128.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
Data about a cookie is received by the browser
a list of cookies for each server (domain)
![Page 129: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/129.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
A cookie is sent to a client by using the Set-Cookie
header field of a HTTP response message
![Page 130: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/130.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
Set-Cookie: name=value; expires=date; path=path;
domain=Internet-domain; secure
![Page 131: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/131.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
Set-Cookie: name=value; expires=date; path=path;
domain=Internet-domain; secure
expires – indicates date and time when cookie will expire (Web client should destroy expired cookies)
![Page 132: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/132.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
Set-Cookie: name=value; expires=date; path=path;
domain=Internet-domain; secure
domain – signifies the symbolic name of the Web server that generated the cookie
![Page 133: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/133.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
Set-Cookie: name=value; expires=date; path=path;
domain=Internet-domain; secure
path – specifies a subset of URLs from the cookie’s domain
distinguishes multiple applications existing on the same server
![Page 134: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/134.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
Set-Cookie: name=value; expires=date; path=path;
domain=Internet-domain; secure
secure – indicates that cookie will be sent back to the server only if the communication channel is “secure”
(via HTTPS)
![Page 135: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/135.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookie-uri
also, consult Cookiepediahttps://cookiepedia.co.uk/
![Page 136: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/136.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
A cookie is transmitted back from the client to the Web server only if it satisfies
all validity conditions
domain, path, expire date & time, and communication channel security are matching
![Page 137: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/137.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
Server will receive, in the headerof a HTTP request message, the following:
Cookie: name1=value1; name2=value2...
the list of cookies which satisfy the validity conditions
![Page 138: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/138.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
A script invocation consists of returning a representation + placing various cookies
Web Server
Web Client
HTTP requestscript invocation
HTTP responseSet-Cookie: color=green
Script
![Page 139: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/139.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
Cookies – persistent or not –are processed and stored by the browser
Web Server
Web Client
Script
color=
green
persistent cookies are stored in files or databases (SQLite)
![Page 140: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/140.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
Next access to the script is made by transmitting the cookies to the server
according to the validity conditions
Web Server
Web Client
Script
color=
green HTTP requestCookie: color=green
HTTP response
![Page 141: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/141.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: creating
An example for PHP – function setcookie ()
<?php
setcookie ("other_color", "blue"); // non-persistent – why?
echo "A cookie of color " . $_COOKIE["other_color"];
?>
![Page 142: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/142.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: expiring
Nullifying the value and expiration date;optionally, the other cookie attributes
example – PHP:
<?php
setcookie ($cookie_name, "", 0, "/", "", 0);
?>
![Page 143: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/143.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: consulting
Cookies reside in the header field of a HTTP message
HTTP_COOKIE
![Page 144: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/144.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies: consulting
PHP – a cookie is specified (accessed) like a variable
$_COOKIE ['cookie_name']
associative array
![Page 145: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/145.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
cookies
Other information of interest is available inRFC 6265
HTTP State Management Mechanism
http://tools.ietf.org/html/rfc6265
![Page 146: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/146.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
How can we identify successive requests expressed by the same client instance?
![Page 147: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/147.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
HTTP is stateless protocol
can not tell if specific successive requests are received from the same client
(from the same instance of a Web browser)
![Page 148: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/148.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
necessity
Preserving certain data for a sequence of relatedHTTP messages (requests/responses)
![Page 149: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/149.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
necessity
Preserving certain data for a sequence of relatedHTTP messages (requests/responses)
examples: shopping cart status
multi-step Web formscontent pagination
user authentication stateetc.
![Page 150: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/150.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
sessions
Each visitor of a Website will have associated a unique identifier – session ID (SID)
stored by a cookie(e.g., ASP.NET_SessionId, PHPSESSID, session-id, _wp_session)
orpropagated via a URL
![Page 151: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/151.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
sessions
Each visitor of a Website will have associated a unique identifier – session ID (SID)
in this way, consecutive visits (requests) made by the same user could be identified
![Page 152: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/152.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
sessions
Various variables could be attached to a session
their values will be kept (stored) between consecutive – e.g., related – requests from the same instance
of a Web client (browser)
![Page 153: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/153.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
sessions
A session could be implicitly (automatically) or explicitly (manually, by programmer) registered,
depending on the Web application server or the default configuration
![Page 154: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/154.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
sessions
A session could be implicitly (automatically) or explicitly (manually, by programmer) registered,
depending on the Web application server or the default configuration
Web session info is persistently stored on the server by using non-relational database systems – e.g., DynamoDB,
Memcached, Redis,… – or, in most cases, files
![Page 155: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/155.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
POST / HTTP/1.1
Accept: text/html,application/xhtml+xml,
application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en,en-GB;q=0.5
Connection: keep-alive
Cookie: language=en_US
Host: mail.info.uaic.ro
Referer: http://mail.info.uaic.ro/?_task=login
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 … Gecko/20100101 Firefox/51.0
user authentication by using POST method(already existing cookies are transmitted)
advanced
![Page 156: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/156.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
sesiuni: exemplificare
HTTP/1.1 302 Found
Cache-Control: private, no-cache, no-store, must-revalidate…
Connection: Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Thu, 23 Feb 2017 10:25:44 GMT
Keep-Alive: timeout=5, max=100
Last-Modified: Thu, 23 Feb 2017 10:25:44 GMT
Location: ./?_task=mail&_token=cb1924…c9c97819
Server: Apache/2.4.6 (CentOS) mod_fcgid/2.3.9 PHP/5.4.16
Set-Cookie: roundcube_sessid=vnqrt4…2uv2; path=/; HttpOnly
roundcube_sessauth=S92ee64…2c71; path=/; HttpOnly
<!DOCTYPE html>
…
HTTP response a Web session-related cookie is set
advanced
redirection after
authentication
![Page 157: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/157.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
sessions: programming
In the case of CGI, session management must be entirely implemented by the programmer
there is no standard way for Web session processing
advanced
![Page 158: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/158.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
sessions: programming
PHP – functions: session_start(), session_register(),session_id(), session_unset(), session_destroy()
<?php
session_start (); // creating a session
if (!isset ($_SESSION['accesses'])) {
$_SESSION['accesses'] = 0; } else {
$_SESSION['accesses']++; }
?>
accesses variable attached to the session
details at http://php.net/manual/en/book.session.php
![Page 159: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/159.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
sessions: programming
By using an application server or framework, the cookie and session management is simpler
various examples:HttpSession class (ASP.NET), HttpSession interface (Java servlets),
HTTP::Session (Perl), session (Flask – Python framework), web.session(web.py), HttpFoundation (component of Symfony – PHP framework),
SessionComponent class (CakePHP), session array (Ruby on Rails),play.mvc.Http.Cookie (Play! for Java/Scala), sessions (Gorilla – Go)cookie-parser and express-session (Node.js modules for Express)
advanced
![Page 160: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/160.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
alternatives
HTML5 provides Web Storage
W3C recommendation (2015)
browser-level storage for lists of key—value pairs via sessionStorage and localStorage attributes
for details, studyprofs.info.uaic.ro/~busaco/teach/courses/cliw/web-film.html#week11
avansat
![Page 161: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/161.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/“conclusion”
⥁from HTTP to cookies and Web sessions
many thanks to Ciprian Amariei, MSc.
![Page 162: Web Technologies - Alexandru Ioan Cuza Universitybusaco/teach/courses/web/presentations/...HTTP/1.1 Internet standard: RFC 2616 (1999) from 2014, defined by RFC 7230—7235 ... 303](https://reader031.vdocuments.site/reader031/viewer/2022022516/5b047b8c7f8b9a41528c9177/html5/thumbnails/162.jpg)
Dr.
Sab
in B
ura
ga
profs.in
fo.uaic.ro/~busa
co/
next episode: Web programmingWeb application servers, Web application architecture
brow-ser
presen-tation
pro-cessing
data access
<Web/> pages
HTML, CSS,…
fat serverdumb client
frontend backend