Tuesday, June 13, 2017

HTTP

HTTP - Hypertext Transfer Protocol




Hyper Text- Text with Links
Transfer- Transfering from here to there
Protocol- Set of Rules

HTTP Simply - A Set of Rules that Transfers the text with Links.

We can use HTTP to get information from any web page on the Internet.

Tim Berners-Lee and his team invented the original HTTP protocol with only one function GET.

Basically, there are 4 functions in HTTP

1.GET

  • Get Information from Source

2.PUT

  • Send Information to Source

3.POST

  • Updating Information to Existing Document

4.DELETE

  • Removing Information from Source
So when we sent our GET request to google.com, we retrieved information. When you add to or update your blog, you're sending POST or PUT requests; when you delete a tweet, there goes a DELETE request.

How Http Works?

The Internet is full of clients who ask for various resources (web pages, files, and so on), and servers, who store that information (or know where to get it). 


When you make an HTTP request, it goes through the Internet until it finds the server that knows how to fulfil that request. Then the server sends a response back to you



Http request

var xhr = new XMLHttpRequest();
xhr.open("GET", "https://www.google.com/", false);

xhr.send();

This is an example for Requesting.

  • Here, In line 1,  xhr variable, which stands for XML HTTP Request. This is how an HTTP request made.
  • In line 2,  we make the real request to google.com.
  • In line 3, This is the place where the request is being sent.!. call the .send() into xhr variable.
A Http Request contains 3 Parts
  1. A request line
    • Tells the server what kind of request is being sent (GET, POST, etc.) and What Resource it's looking for.
  2. A header
    • Sends the server additional information (such as which client is making the request)
  3. A body
    • Contains information about POST, PUT

Http response


HTTP/1.1 200 OK
 Content-Type: text/xml; charset=UTF-8

<?xml version="1.0" encoding="utf-8"?>

<string xmlns="http://www.codecademy.com/">

Accepted</string>


This is an example for Responding.

The HTTP response structure current opponent that of the HTTP request.
  1. response line
    • Contains the three-digit HTTP status code and a Message.
  2. A header
    • Contains information about the server and its response.
  3. body
    • Contains the text of the response.


Http Status Code

The response from the server will contain a three-digit status code.

The Codes start with a 1, 2, 3, 4, or 5, and each set of codes means something different.
  1. 1XX
  2. 2XX
  3. 3XX
  4. 4XX
  5. 5XX





No comments:

Post a Comment

My First Day with Uki DN Cohort 1

 "Hello WORLD!"