Unknown

Introduction to Web

Introduction to Web

Web consists of billions of clients and server connected through wires and wireless networks. The web clients make requests to web server. The web server receives the request, finds the resources and return the response to the client. When a server answers a request, it usually sends some type of content to the client. The client uses web browser to send request to the server. The server often sends response to the browser with a set of instructions written in HTML(HyperText Markup Language). All browsers know how to display HTML page to the client.
client and server functioning

Web Application

A website is a collection of static files(webpages) such as HTML pages, images, graphics etc. A Web application is a web site with dynamic functionality on the server. GoogleFacebookTwitter are examples of web applications.

HTTP (Hypertext Transfer Protocol)

  • HTTP is a protocol that clients and servers use on the web to communicate.
  • It is similar to other internet protocols such as SMTP(Simple Mail Transfer Protocol) and FTP(File Transfer Protocol) but there is one fundamental difference.
  • HTTP is a stateless protocol i.e HTTP supports only one request per connection. This means that with HTTP the clients connect to the server to send one request and then disconnects. This mechanism allows more users to connect to a given server over a period of time.
  • The client sends an HTTP request and the server answers with an HTML page to the client, using HTTP.
HTTP protocol and its characteristics

HTTP Methods

HTTP request can be made using a variety of methods, but the ones you will use most often are Get and Post. The method name tells the server the kind of request that is being made, and how the rest of the message will be formated.
HTTP Methods and Descriptions :
Method Name
Description
OPTIONSRequest for communication options that are available on the request/response chain.
GETRequest to retrieve information from server using a given URI.
HEADIdentical to GET except that it does not return a message-body, only the headers and status line.
POSTRequest for server to accept the entity enclosed in the body of HTTP method.
DELETERequest for the Server to delete the resource.
CONNECTReserved for use with a proxy that can switch to being a tunnel.
PUTThis is same as POST, but POST is used to create, PUT can be used to create as well as update. It replaces all current representations of the target resource with the uploaded content.

Difference between GET and POST requests

GET Request
POST Request
Data is sent in header to the serverData is sent in the request body
Get request can send only limited amount of dataLarge amount of data can be sent.
Get request is not secured because data is exposed in URLPost request is secured because data is not exposed in URL.
Get request can be bookmarked and is more efficient.Post request cannot be bookmarked.

General Difference between PUT and POST methods

Following are some basic differences between the PUT and the POST methods :
  • POST to a URL creates a child resource at a server defined URL while PUT to a URL creates/replaces the resource in its entirety at the client defined URL.
  • POST creates a child resource, so POST to /books will create a resources that will live under the /booksresource. Eg. /books/1. Sending the same post request twice will create two resources.
  • PUT is for creating or replacing a resource at a URL known by the client.
  • PUT must be used for CREATE when the client already knows the url before the resource is created.
  • PUT replaces the resource at the known url if it already exists, so sending the same request twice has no effect. In other words, calls to PUT are idempotent.

Anatomy of an HTTP GET request

Get request contains path to server and the parameters added to it.
Anatomy of Get request method

Anatomy of an HTTP POST request

Post requests are used to make more complex requests on the server. For instance, if a user has filled a form with multiple fields and the application wants to save all the form data to the database. Then the form data will be sent to the server in POST request body, which is also known as Message body.
Anatomy of Post request method