Before you go, check out these stories!

0
Hackernoon logoHTTP and Web Servers by@ashwin

HTTP and Web Servers

;
Author profile picture

@ashwinashwin

Front End Developer

HTTP (Hypertext Transfer Protocol) is the language that web browsers and web servers speak to each other. Example, Request a web page or download a file or watch a video, it is HTTP that makes it possible.

1 — Building Blocks Of HTTP

An HTTP transaction always involves a Client and Server. Loading a page may take many requests sometimes to different servers. Example, When you are reading a News on News Website you are requesting the content from the server where it has been hosted and when you are watching an embedded video from the same page, you may be requesting the video from another web server such as a YouTube Web Server.

Web address is also called a URI (Uniform Resource Identifier). From a web user’s view, URI is just a piece of text that you put into your web browser that tells it which page to go. URI is made up of several different parts.

Hostname — is a part of the URI, that tells the browser which web server to connect to. Example, www.twitter.com

The browser has to extract the hostname from the URI, look it up to find the IP Address, and then connect to the right port number on that IP address. Example, 104.244.42.1:700

2 — Web Server and Client Programs Communication

Types of HTTP Requests

Every request contains an HTTP verb or method, which tells the server what the client is asking it to do.

  1. GET
  2. POST
  3. PUT
  4. PATCH
  5. DELETE

1 — GET

GET is one of many HTTP verbs or methods. This is what browser use whenever they ask a server to send them a copy of a web page or an image or another request. HTTP Response to a GET request is going to be whatever it is that the server has to send back to fulfill the client’s request. That could be a piece of HTML or an image or some other data. The GET method is really for requesting a copy of a resource.

As a software developer, you will deal with a lot of different formats — HTML, XML, CSV, JSON, PNG, SVG, MP3. Data formats that are really common for Web APIs is called JSON (JavaScript Object Notation), it’s based on the syntax of JavaScript.

One of the parts a URI can have is a query part.

Example: https://www.google.com/search?q=hackernoon

Most of the time, query parameters don’t get into a URI by the user typing them out into the browser. Query parameters often come from a user submitting in HTML form.

Sending HTTP Request over to the server is defined by HTTP Request Line.

Method Request-Target HTTP-Version

GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1

Here GET is the method, URI is the Request-target and HTTP/1.1 is the Version.

2 — POST

Used a lot with Forms. POST is for things that act more or less like a form submission.

Ways to Architect a web app

  • Single page apps.
  • Apps with a lot of clients logic.
  • Apps that are almost entirely on the server.
  • Apps with a whole bunch of different servers.

Common Design Pattern for Server side web apps using forms.

POST-Redirect-To-GET Pattern

POST-REDIRECT-GET is a pattern that says a POST action should always REDIRECT to a GET action. This pattern is meant to provide a more intuitive interface for users, specifically by reducing the number of duplicate form submissions.

A server that accepts requests as a web server, can sometimes make a request as a web client.

3 — PUT

The PUT method completely replaces whatever currently exists at the target URL with something else. With this method, you can create a new resource or overwrite an existing one given you know the exact Request-URI. In short, the PUT method is used to create or overwrite a resource at a particular URL that is known by the client.

4 — PATCH

The PATCH method is a request method supported by the HTTP protocol for making partial changes to an existing resource. The PATCH method provides an entity containing a list of changes to be applied to the resource requested using the HTTP URI. The list of changes is supplied in the form of a PATCH document.

5 — DELETE

HTTP DELETE request method deletes the specified resource.

Syntax: DELETE /file.html HTTP/1.1

3 — Web Hosting, Web Services, and Cookies

Important Terminologies

URL Shortening — A URL shortener is a Web site that will create a short Uniform Resource Locator (URL) or Web page address from a long one so that the short version, which is easier to remember and enter, can be used instead.

Web Cookies — A small text file (up to 4 KB) created by a website that is stored in the user’s computer either temporarily for that session only or permanently on the hard disk (persistent cookie). Cookies provide a way for the website to recognize you and keep track of your preferences.

Localhost — “Localhost” refers to the local computer that a program is running on. For example, if you are running a Web browser on your computer, your computer is considered to be the “localhost.” … The local machine is defined as “localhost,” which gives it an IP address of 127.0.0.1.

Deployment — In its IT context, deployment encompasses all the processes involved in getting new software or hardware up and running properly in its environment, including installation, configuration, running, testing, and making necessary changes.

Popular Web Servers — These specialized web servers handle a large number of requests very quickly.

  1. Apache
  2. NGINX
  3. Microsoft IIS

HTTP Headers

There are a couple of particular headers, that is especially important for web applications.

  1. Set_Cookie
  2. Cookie

These Headers are used to store and transmit cookies. An HTTP cookie is a piece of data that a web server asks a browser to store and send back. Cookies are immensely important to many web apps. They make it possible to stay logged in to a website or to associate multiple queries into a single session. And they are also used to track users for advertising purposes.

HTTPs

  1. An encrypted version of HTTP.
  2. HTTPS websites have a green lock on the address bar.
  3. https:// in the URI.
  4. Originally HTTPs was used to protect the credit card information, passwords, and other high-security information.
  5. As web security and privacy got more and more important, a lot of major sites started using HTTPs on every connection.
  6. HTTPs does two really important things.
  • It protects your data from the Eavesdroppers (is the act of secretly or stealthily listening to the private conversation or communications of others without their consent) on the network.
  • Checks the authenticity of the site you’re talking to.

APIs are a huge part of the modern web, a lot of web applications make use of a server-side part that exposes an API and the client side part that sends queries to that API.

HTTP

The first version of HTTP didn’t even have a version number on it, but it was later called version 0.9. It only supported GET Requests and expected all Responses to be in HTML and it didn’t even have any Headers.

HTTP 1.0–1996

It added headers, POST Requests for forms, status codes and Content types.

HTTP 1.1 — (1999–2007)

  1. Improved Caching controls.
  2. Range Requests (Resuming downloads).
  3. Transfer encoding (Compression).
  4. Persistent Connection.
  5. Chunk Messages.
  6. Ability to host multiple websites on the same server and IP Address by using the HOST header.

HTTP 2–2012

  1. Much more efficient especially for busy services.
  2. Multiplexing (Many requests at once).
  3. Better Compression.
  4. Server push.

HTTP Status Codes

  1. 200 — OK, Success
  2. 301 — Moved Permanently
  3. 302 — Found, Redirected to new URL
  4. 304 — Not Modified
  5. 401 — Unauthorised
  6. 403 — Forbidden
  7. 404 — Not Found
  8. 418 — I’m a Teapot, (April Fool)
  9. 500 — Internal Server Error
  10. 504 — Gateway timeout (Timeout loading)

Web Hosting

Web hosting is a service that allows organizations and individuals to post a website or web page onto the Internet. A web host, or web hosting service provider, is a business that provides the technologies and services needed for the website or web page to be viewed on the Internet. Websites are hosted or stored, on special computers called servers. When Internet users want to view your website, all they need to do is type your website address or domain into their browser. Their computer will then connect to your server and your web pages will be delivered to them through the browser.

Most hosting companies require that you own your domain in order to host with them. If you do not have a domain, the hosting companies will help you purchase one.

What is Web Service?

Web service is a standardized medium to propagate communication between the client and server applications on the World Wide Web.

Web services provide a common platform that allows multiple applications built on various programming languages to have the ability to communicate with each other.

SOAP — Simple Object Access Protocol

SOAP was developed as an intermediate language so that applications built on various programming languages could talk quickly to each other and avoid the extreme development effort.

WSDL — Web Services Description Language

WSDL is an XML-based file which tells the client application what the web service does and gives all the information required to connect to the web service.

REST — REpresentational State Transfer.

REST is used to build Web services that are lightweight, maintainable, and scalable.

The Concepts cover Introductory level of understanding of HTTP and Web Servers, which is enough to give you a quick start in your work. Thanks for reading and Have a Good Day… 😃. Also don't forget to share with like minded people

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.