• 0

What is HTTP? And what is it used for?

HTTP is the abbreviation for Hyper Text Transfer Protocol. Hyper Text means HTML pages. The protocol is one of the protocols included in the application layer of TCP/IP which works on top of TCP (Transmission Control Protocol) that provides a connection oriented reliable bytes stream connection. In easier way to say, HTTP works like there is already connection between source and destination that accepts text data. The protocol is composed from HTTP Request and HTTP Response each of them has certain keywords to distinguish type or request or response status.
http

Types of HTTP Requests

  • The first HTTP request type is GET request, its syntax is as following:-

    GET means a get request that is asks for a resource located at the server. The resource location in the example is /index.html which refers to the file index.html located at the root directory. Also index.html can be omitted and replaced with just /
    HTTP/1.0 is the protocol version used.

  • The second HTTP request type is POST request, its syntax is as following:-

    POST means a posting data to some script located at the server. The script location in the example is /path/to/script.php. The data posted is var1=value and var2=value2 here, two variable posted to the script. It is the responsibility of the script to fetch and interpret those values.
    HTTP/1.0 is the protocol version used.

  • The third HTTP request type is PUT Request:-

    From the example above, a PUT request is pretty much the same as POST request the main difference is that PUT request usually used to either create new resource or replace existing resource. While POST is historically used to create new resource only. Of course this is up to the handler script and not part of the protocol itself.

  • The last HTTP request type is DELETE request:-

    The server is requested to delete the indicated resource or move it to inaccessible location.

HTTP Response Codes

  • 200

    Means success or resource found.

  • 400

    Means the request is malformed or not supported by the server.

  • 401

    Means to access the required resource an authorization headers required.

  • 403

    Means the requested resource is forbidden. An authorization will not help.

  • 404

    Means the requested resource or file not found.

  • 500

    The server encountered a fatal condition which prevented it from responding to the request.

  • 301

    Means the requested resource moved to the indicated location permanently.

  • 302

    Means the requested resource moved to the indicated location temporarily
    .

  • 304

    Means the requested resource found but has not been modified since last cached version.

Finally, the following figure depict a real HTTP request and response and shows some of the most commonly used headers.
http-request-response


Leave a Reply

%d bloggers like this: