Application Protocols: HTTP CSNB534 Semester 2, 2007/2008 Asma Shakil.

Slides:



Advertisements
Similar presentations
4.01 How Web Pages Work.
Advertisements

TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
PART 6 Application Layer
HTTP HyperText Transfer Protocol. HTTP Uses TCP as its underlying transport protocol Uses port 80 Stateless protocol (i.e. HTTP Server maintains no information.
Prepared By E. Musa Alyaman1 URLs, InetAddresses, and URLConnections Chapter 9.
How the web works: HTTP and CGI explained
Internet Programming In Java. References Java.sun.com Java552 Many of the programs shown.
World Wide Web1 Applications World Wide Web. 2 Introduction What is hypertext model? Use of hypertext in World Wide Web (WWW) – HTML. WWW client-server.
CIS – Spring Instructors: Geoffrey Fox, Bryan Carpenter Computational Science and.
13-Jul-15 Sockets and URLs. 2 Sockets A socket is a low-level software device for connecting two computers together Sockets can also be used to connect.
Implementing Application Protocols. Overview An application protocol facilitates communication between applications. For example, an client uses.
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Hypertext Transport Protocol CS Dick Steflik.
 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.
PL-IV- Group A HTTP Request & Response Header
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
HTTP; The World Wide Web Protocol
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Computer Networks  Network - A system of computers interconnected in order to share information.  Data transmission - consists of sending and receiving.
Web Architecture Dr. Frank McCown Intro to Web Science Harding University This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
Chapter 1: Introduction to Web
Appendix F: Network Programming in Java ©SoftMoore ConsultingSlide 1.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
HyperText Transfer Protocol (HTTP).  HTTP is the protocol that supports communication between web browsers and web servers.  A “Web Server” is a HTTP.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
A Closer Look at HTTP HyperText Transfer Protocol.
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
NETWORK PROGRAMMING.
Overview Web Session 3 Matakuliah: Web Database Tahun: 2008.
Form Data Encoding GET – URL encoded POST – URL encoded
Chapter 29 World Wide Web & Browsing World Wide Web (WWW) is a distributed hypermedia (hypertext & graphics) on-line repository of information that users.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
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.
2: Application Layer 1 Chapter 2: Application layer r 2.1 Principles of network applications  app architectures  app requirements r 2.2 Web and HTTP.
CITA 310 Section 2 HTTP (Selected Topics from Textbook Chapter 6)
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
URL Programming Mimi Opkins CECS277. What is a URL?  URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on.
1 Unraveling the Web: How Does it All Work?. 2 Web Enabling Technologies F TCP/IP network (Internet & others) F URLs F HTTP protocol and HTTP Servers.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
WWW and HTTP King Fahd University of Petroleum & Minerals
HTTP – An overview.
Hypertext Transfer Protocol
Networking CS 3470, Section 1 Sarah Diesburg
Network Programming Introduction
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CASE STUDY -HTML,URLs,HTTP
Network Programming Introduction
Sockets and URLs 17-Sep-18.
Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Sockets and URLs 13-Nov-18.
Clients and Servers 19-Nov-18.
Chapter 27 WWW and HTTP.
URL in Java C343 Lab (Week 13).
Clients and Servers 1-Dec-18.
Networking.
Sockets and URLs 3-Dec-18.
HyperText Transfer Protocol
Uniform Resource Locator: URL
Clients and Servers 19-Jul-19.
Clients and Servers 13-Sep-19.
Presentation transcript:

Application Protocols: HTTP CSNB534 Semester 2, 2007/2008 Asma Shakil

What is HTTP? HTTP (HyperText Transfer Protocol) is an application-level protocol that uses the TCP as a transport mechanism. HTTP originated as a means of sharing documents across the Internet. By placing a hyperlink over a word, users would be able to jump instantly from one document to another, even though the document could reside on servers located in another country. Published as RFC 1954, pioneered by Tim Berners- Lee.

How does HTTP work? When an HTTP client, such as a Web browser or a search engine, needs to access a file, it establishes a TCP connection to the Web server. Which by default uses TCP port 80 for connection. The client sends a request for a particular file and receives an HTTP response Which will often include the contents of the file.

How does HTTP work? The response includes A status code (success/failure of a request) HTTP header information Content-Length Size of item in octets Content-Type Type of item Content-Encoding Encoding used for item Content-Language Language(s) used in item  Example Of Header  Content-Length: 34  Content-Type : text/html  Content-Language: english  Content-Encoding: ascii The file contents (if appropriate)

Web Clients Under HTTP/1.0, there are three types of requests that a client application can issue to a web server: GET HEAD POST

GET Request Method Used when a client needs to retrieve a resource from a web server. Takes three parameters Pathname of the resource CGI Parameters (for CGI scripts) : to support interactive pages rather than just static pages. Version of HTTP being used For example GET /cgi-bin/birthday.pl?month=august&date=24 HTTP/1.0

HEAD Request Method If the client is interested in information about a resource but not the resource itself. Example HEAD /files/bigfile.zip /HTTP/1.0 Returns only the header fileds.

Example Code for WebServer Demo.

HTTP and Java While developers are free to write, their own HTTP implementations using TCP, the java.net package provides several in-built classes that offer HTTP functionality Java.net.URL Java.net.URLConnection Java.net.HttpURLConnection

URL Class URLs can point to Files Web sites ftp sites Newsgroups addresses Examples ftp://metalab.uniten.edu.my/~asma/csnb334/ telnet://localhost:8000/ Components of a URL Protocol :// hostname (:port) – optional Path (can include the CGI parameters also after a ?) (#reference) – optional - fragment identifier

Creating a URL Constructors Six constructors URL(String url_str) Creates a URL object based on the string parameter. URL(String protocol, String host, String file) Creates a URL object based with the specified protocol, host and file path. URL(String protocol, String host, int port, String file) Creates a URL object based with the specified protocol, host, port and file path. URL(String protocol, String host, int port, String file, URLStreamHandler handler) Creates a URL object based with the specified protocol, host, port and file path and stream handler. URL(URL context, String relative) Creates a URL object using the context of an existing URL and relative URL E.g. URL = relative URL = /images/icon.gifhttp://somewebsite.com Resulting URL URL(URL context, String relative, URLStreamHandler handler) All of them throw java.net.MalformedURLException if the URL cannot be correctly parsed.

Using a URL The URL class provides the following methods to parse a URL and extract individual components as well as to open an HTTP connection to the resource that it specifies. Methods Object getContent() Retrieves the contents of the resource located at the URL. String getProtocol() Returns the protocol component of a URL String getHost() Returns the host component of a URL. String getPort() Returns the port component of a URL. String getFile() Returns the pathname component of a URL. String getRef() Returns the reference component of a URL. URLConnection openConnection() Returns a URLConnection object which can be used to establish a connection to the remote resource. InputStream openStream() Establishes a connection to the remote server where the resource is located and provides an input stream to read the resource’s contents

A Simple Example Parsing with the URL Class

Running URL parser Valid URLS ftp://ftp.metelab.uniten.edu.my/~asma Invalid URLS ttp:// abcdef://abcdef.com/absoup/

Retrieving a Resource with the URL Class To retrieve a resource using the URL class InputStream URL.openStream() URLConnection URL.openConnection() A simple example to fetch a URL.fetch a URL

URLConnection Class The URLConnection Class is used to send HTTP requests and read HTTP responses. URLConnection allows you to Connect to a web server. Set request header fields Read response header fields Read the contents of the resource.

Creating a URLConnection No public constructors for the URLConnection class. Instead, call the URL.openConnection() method which returns a URLConnection instance. URL myURL = new URL (_some URL_); URLConnection connection = myURL.openConnection();

Using a URLConnection Methods Void connect(); The act of creating a URLConnection object does not establish a connection with the remote host until this method is called. Object getContent(); Process the contents of a resource and return it as an Object. String getContentEncoding(); Returns the value of the “Content-encoding” header field. int getContentLength(); Returns the value of the “Content-length” header field. String getContentType(); Returns the value of the “Content-type” header field.

Content-type Type application: Multipurpose files application/javascript: Javascript application/octet-stream: Arbitrary byte stream. This is thought of as the "default" media type used by several operating systems, often used to identify executable files. application/x-shockwave-flash: Adobe Flash files; Type audio: Audio audio/mpeg: MP3 audio/x-ms-wma: Windows Media Audio; audio/x-wav: WAV audio Type text: Human-readable text and source code text/html: HTML; text/plain: Textual data; text/xml: Extensible Markup Language; Type video: Video video/mpeg: MPEG-1 video/mp4: MP4 video; video/quicktime: QuickTime video; video/x-ms-wmv: Windows Media Video;

Using a URLConnection Methods InputStream getInputStream(); Returns an input stream object that reads the resource’s contents pointed to by the URLConnection. OutputStream getOutputStream(); Returns an output stream object that writes to the remote connection pointed to by the URLConnection. If the connection does not support writing  UnknownServiceException.

A Simple Example Retrieving a resource with the URLConnection Class Retrieving a resource with the URLConnection Class