How does it work ?.

Slides:



Advertisements
Similar presentations
Hypertext Transfer PROTOCOL ----HTTP Sen Wang CSE5232 Network Programming.
Advertisements

PHP syntax basics. Personal Home Page This is a Hypertext processor It works on the server side It demands a Web-server to be installed.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
HTTP – HyperText Transfer Protocol
How the web works: HTTP and CGI explained
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University.
 What is it ? What is it ?  URI,URN,URL URI,URN,URL  HTTP – methods HTTP – methods  HTTP Request Packets HTTP Request Packets  HTTP Request Headers.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Introduction to Web Programming Fall 2014/2015 Some slides are based upon Web Technologies course slides, HUJI, 2009 Extended System Programming Laboratory.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
Server-side Scripting Powering the webs favourite services.
Maryam Elahi University of Calgary – CPSC 441.  HTTP stands for Hypertext Transfer Protocol.  Used to deliver virtually all files and other data (collectively.
Web HTTP Hypertext Transfer Protocol. Web Terminology ◘Message: The basic unit of HTTP communication, consisting of structured sequence of octets matching.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
HTTP1 Hypertext Transfer Protocol (HTTP) After this lecture, you should be able to:  Know how Web Browsers and Web Servers communicate via HTTP Protocol.
Appendix E: Overview of HTTP ©SoftMoore ConsultingSlide 1.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
Web Technologies Lecture 3 Web forms. HTML5 forms A component of a webpage that has form controls – Text fields – Buttons – Checkboxes – Range controls.
Web Technologies Lecture 1 The Internet and HTTP.
CS 6401 The World Wide Web Outline Background Structure Protocols.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Overview of Servlets and JSP
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
What’s Really Happening
National College of Science & Information Technology.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Hypertext Transfer Protocol
Tiny http client and server
Block 5: An application layer protocol: HTTP
How HTTP Works Made by Manish Kushwaha.
WWW and HTTP King Fahd University of Petroleum & Minerals
Building Web Apps with Servlets
Web Basics: HTML and HTTP
Hypertext Transfer Protocol
HTTP – An overview.
The Hypertext Transfer Protocol
CISC103 Web Development Basics: Web site:
Web Development Web Servers.
1993 version of Mosaic browser.
COMP2322 Lab 2 HTTP Steven Lee Feb. 8, 2017.
HTTP Protocol Specification
Hypertext Transport Protocol
Introduction Web Environments
HTTP Protocol.
Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CISC103 Web Development Basics: Web site:
WEB API.
Chapter 27 WWW and HTTP.
HTTP Hypertext Transfer Protocol
Hypertext Transfer Protocol
HTTP Request Method URL Protocol Version GET /index.html HTTP/1.1
Hypertext Transfer Protocol
Hypertext Transfer Protocol
HyperText Transfer Protocol
EE 122: HyperText Transfer Protocol (HTTP)
Hypertext Transfer Protocol (HTTP)
CS3220 Web and Internet Programming Handling HTTP Requests
Hypertext Transfer Protocol
Kevin Harville Source: Webmaster in a Nutshell, O'Rielly Books
The HTTP Protocol COSC 2206 Internet Tools The HTTP Protocol
Introduction to World Wide Web

HTTP Hypertext Transfer Protocol
Hypertext Transfer Protocol
CSCI-351 Data communication and Networks
Presentation transcript:

How does it work ?

Hypertext Transfer Protocol (HTTP) A communication protocol It is used to communicate between a client and a web server It is the network protocol of the web Let us take a look on a typical scenario

1) Typing a URL The browser/client parses the URL The URL pattern is: protocol://server:port/requestURI?arg1=val1&…&argN=valN Protocol: in our case HTTP Server : Server location (e.g. www.NBA.com) Port: port that the web server listens to (default:80) Request-URI: web server resource (e.g. index.html) Arg: argument ( e.g. username) Val: values for the argument (e.g.JohnnyCash)

2) Sending HTTP-Request The browser decides which information to send The browser sends a text called request to the server Request pattern: [METHOD] [REQUEST-URI] HTTP/[VER] [fieldname1]: [field-value1] [fieldname2]: [field-value2] [request body, if any] The server knows how to handle/parse a request

Request methods Get Method Post Method and more: HEAD, DELETE .. Data is visible in the URL GET requests can be cached GET requests remain in the browser history GET requests should never be used when dealing with sensitive data GET requests have length restrictions GET requests should be used only to retrieve data Post Method Data is not displayed in the URL POST requests are never cached POST requests do not remain in the browser history POST requests cannot be bookmarked POST requests have no restrictions on data length and more: HEAD, DELETE ..

Request example GET /players/mJordan/info.html HTTP/1.1 Host: www.nba.com User-Agent: Mozilla/5.0 (Windows;) Gecko Firefox/3.0.4 Accept: text/html,application/xhtml+xml,application/xml; Accept-Language: en-us,en;q=0.5 X-cept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive [no body]

Conditions in request It’s possible to add conditions in the HTTP request Syntax: If-Match, If-None-Match, If-Range, If-Unmodified-Since, If-Modified-Since Servers along the way can change the request how do we call these servers? Why would we use it?

3) Server Processing The web-server listens to specific ports (usually 80) It receives the request and parse it Typical web-server (Get method) has a mapping between resource-URI to the local hard-drive

4) Server response The server sends back information and content back to the user-agent Response pattern: HTTP/1.0 code text Field1: Value1 Field2: Value2 ...Document content here... (e.g. HTML code)

Status codes The status code is a three-digit integer, and the first digit identifies the general category of the response: 1xx indicates an informational message (mostly for experimental purposes only) 2xx indicates success of some kind (e.g. 200 OK) 3xx redirects the client to another URL 301 Moved permanently 302 Moved temporarily 4xx indicates an error on the client's part 400: Bad request ( bad syntax mostly) 401: Unauthorized (e.g. wrong user/pass) 403: Forbidden ( e.g. not allowed client) 404: Not found 5xx indicates an error on the server's part 500: Internal server error

Response example HTTP/1.0 200 OK Date: Fri, 31 Dec 1999 23:59:59 GMT Content-Type: text/html Content-Length: 1354 <html> <body> <h1>Hello World</h1> </body> </html>

Persistence (HTTP) When the browser receives and renders HTML, it sends new request to get any resource the HTML points to (e.g. images) Basically the connection is closed after a single request/response pair Each request creates new TCP connection Creating TCP connection is super-slow

Persistence – (cont’d) HTTP 1.1 (1999) keep-alive-mechanism: The browser creates one TCP connection and sends many request through it

Stateless The HTTP protocol doesn’t save any information in a request that can be used in a different request later on Advantage? If a client dies in mid-transaction, no part of the system needs to be responsible for cleaning the present state of the server Disadvantage? User responsibility

Caching Browser Caching Proxy Caching Browser caches most resources in a temporary folder Browser sends a request to check if it has the most updated resource Proxy Caching Some servers along the way hold cache of resources

“Talking” with the server The user communicate with the web server through HTML forms The user fills in the form and hits the submit button, upon which the data is submitted to the server The <FORM> tag has a method attribute E.g. <form method=“post”>

Submitting forms GET: form data are encoded into the URL Disadvantages ? POST: the HTTP request will include a body that contains the parameters Rule of thumb: Primarily, POST should be used when the request causes a permanent change See Example: form_get.html

Static Web Pages Stored as files in the file system Delivered to the user exactly as stored Same information for all users, from all contexts via HTTP Large numbers of static pages as files can be impractical

Cascading Style Sheets (CSS) CSS is a style sheet language used to describe the presentation of a document written in HTML Styles define how to display HTML elements External Style Sheets can save you a lot of work External Style Sheets are stored in CSS files HTML code become cleaner and less messy HTML pages become richer and user-friendly see example: Zen Garden

Dynamic web pages A web page with web content that varies based on parameters provided by a user or a computer program Client-side scripting generally event driven, using the DOM elements Server-side scripting servers response affected by HTML forms, browser type, etc’ Combination  using Ajax

Dynamic web pages – (cont.) Client-side scripting (JavaScript, Flash, etc.) client-side content is generated on the user's local computer system event-driven can appear in events on HTML or separately Pros: nice and dynamic Cons: slow, browsers behave differently

Dynamic web pages – (cont.) Server–side scripting (PHP, Perl, Ruby, etc.) Server processes script on request Server provides client-designated HTML Stateful behavior on stateless protocol See example: WebGT

Combination - Basic Ajax Not a cleaning spray

Combination - Basic Ajax Not a soccer team

Combination - Basic Ajax Asynchrony JavaScript And XML Sending requests to the server without refreshing the page Using Javascript code Client side uses callback functions to manipulate server responses Do you remember such behavior from Facebook? See example: WebGT

Pros and Cons Pros Better layout Efficiency – Instead of getting an entire page we retrieve the needed data only Reduce the number of connections (css/images/js) Cons the browser can’t register an Ajax action as a different page – No back button