Fundamentals of WEB Programming
The Web There is no such protocol, called “WEB”, it is a non-technical expression! HTTP: The protocol used by modern web browsers to access webpages. It is a client-server textual protocol (originally a 7-bit protocol!) that uses host names Client: The computer that initiates the connection Server: The computer that accepts the connection and provides the data
Subdomain/IP assignments A DNS zone file Subdomain/IP assignments
How it works? Internet Home network Root NS Provider Home network facebook.com
How to start? The future owner of facebook.com buys a computer (real or virtual) and subscribes an internet connection The internet connection must be 7/24, unfiltered, with a static IPv4 address (IPv4 exhausted: 2011-2015, only available from ISPs) Then the domain name facebook.com must be registered via a domain registrator (registrar), and must be renewed once in every 1-2-3 years The root servers contain every IP-DNS association. Only dedicated (“country- level”) DNS servers can access the root name servers. Every other computer must use the name server provided by the ISP (Alternative: 8.8.8.8)
DNS resolution Send results (or authority info) Local cache Send results (or authority info) Not in cache Home router Send results (or authority info) Not in cache ISP Not in cache Send results (or authority info) Root / additional DNS
Internet vs. WEB Internet marika.hu zoo.com theater.com school.com receptek.html cats.html allatok.html dogs.html marika.hu zoo.com intro.html math.html Internet faq.html arts.html theater.com school.com
WEB: The documents spreaded all over the world can link to each other Internet vs. WEB WEB: The documents spreaded all over the world can link to each other receptek.html cats.html allatok.html dogs.html marika.hu zoo.com intro.html math.html Internet faq.html arts.html WEB theater.com school.com
Three standards hirek allas cimlap.html URL (Uniform Resource Locator) http://origo.hu/hirek/belfold.html belfold.html allas http://origo.hu/allas/ajanlatok.html ajanlatok.html http://origo.hu/cimlap.html cimlap.html
Three standards HTML (Hyper Text Markup Language) Document formatter standard Extensible with other document parts (e.g. styles=CSS, scripts=JS) <table border = "1"> <tr> <th>I. hely</th> <th>II. hely</th> <th>III. hely</th> </tr> <td>Béla</td> <td>Gizi</td> <td>Saci</td> </table> eredmeny.html contents Shown in browser
Three standards HTTP (Hyper Text Transfer Protocol)
HTTP Testable from home Execute -> cmd.exe Install telnet: pkgmgr /iu:"TelnetClient„ Establish TCP connection: telnet users.nik.uni-obuda.hu 80 Send command: GET /kovacs.andras/webprog/hello.html HTTP/1.0 Host: users.nik.uni-obuda.hu
HTTP GET /kovacs.andras/webprog/hello.html HTTP/1.0 HTTP commands GET method We want the contents of the document URL without hostname Full path, filename with extension Version number 1.0 or 1.1 HTTP/2: published in the end of 2015 13.7% supported in May 2017
HTTP HTTP methods Method Description HEAD GET POST PUT DELETE Get only the HTTP headers GET Get the whole document POST Send data to server (form data, can encode files too) PUT Send file to the server (Historically. Now: REST API) DELETE Remove file from the server (Historically. Now: REST API)
HTTP HTTP is a stateless protocol – no built-in session management By default, every request is connection:close Even when using connection pooling, two requests cannot be paired Solution: cookies/sessions Local vs server-side storage
Cookies OE NIK PHP/Symfony
Session OE NIK PHP/Symfony