Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If HTTP is Hyper Text Transfer Protocol, how can we upload documents and images? [closed]

As far as I understand, HTTP stands for Hyper Text Transfer Protocol, in which you transfer/receive data to/from a web-server in text format. If this is the case, how are we able to submit or upload documents/images to a web-server?

like image 818
Vinayjava Avatar asked Mar 14 '13 22:03

Vinayjava


People also ask

Does HTTP transfer images?

Yes. That is how you can transmit any file. Everything is composed of bytes, and every protocol (including HTTP) is essentially an elaborate way to transmit, receive, and interpret bytes.

What is Hypertext Transfer Protocol HTTP used for?

Hypertext Transfer Protocol (HTTP) is an application-layer protocol for transmitting hypermedia documents, such as HTML. It was designed for communication between web browsers and web servers, but it can also be used for other purposes.

Which protocol is used for the transfer of hypertext documents on the Internet?

The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems. HTTP has been in use by the World-Wide Web global information initiative since 1990.

What two types of requests are used with Hypertext Transfer Protocol?

There are two types of HTTP messages, requests and responses, each with its own format.


2 Answers

HTTP means, as you stated, Hyper Text Transfer Protocol. HTTP functions as a request-response protocol in a client-serving computer. This means that when you navigate using a web browser on your computer (the client - such as Firefox or Chrome), you are requesting the information from that web site.

In response to your question: everything is transferred as bytes. A group of words are consisted of a string of bytes, a word document is a string of bytes, and an image is, you guessed it, a string of bytes. HTTP is the way that browsers can talk to a server, and using specific commands, users can submit their data (their string of bytes) to a server.

Historically, a byte was the number of bits used to encode a single character of text in a computer. In very simple terms, all data is consisted of bytes, and HTTP is one way that you can transfer those bytes from A to B. Other ways include FTP, POP3, UDP and TCP/IP.

Very briefly, HTTP works by sending and receiving commands to and from servers. The two commonly used methods for a request-response between a client and server are GET and POST. A GET request requests data from a specified resource (in bytes), and a POST submits data to be processed to a specified resource (also in bytes). Your computer will then convert those bytes to an understandable format - for example:

  1. You navigate to an image on a website (download it). The browser recognises that it is an image (by a number of ways, but for now, we will say the image is a .png file). Your browser recognises that it has an image to download, and converts those bytes between the image tags to render it as an image. You then see your image loaded on a screen (joy!).

  2. You upload a word document to a website. HTTP sends a POST request to the server with the document attached, and it sends the document as a string of bytes. The server will then put it in a place that you or it will specify, and you have uploaded your word document - a long string of bytes, to a server.

So, long story short, everything is converted to bytes. A document sitting on your computer and an image downloaded from a website, both consist of a different amount and combination of bytes.

I really have no degree in any computer science, and have taken a shot at explaining this. You can, however, find more information from the following links:

HTTP methods - GET vs POST

Byte - information storage unit

List of network protocols

like image 60
eggy Avatar answered Sep 22 '22 12:09

eggy


HTTP allows you to specify the type of data you are transferring with the Content-Type header. The contents are not necessarily text, but can be any byte stream.

HTTP/1.1 200 OK
Server: carrier pigeon
Content-Type: image/jpeg
Date: today

...contents...

The HTTP headers, request message, and response message are all plain text, but the content does not have to be text.

The original version of HTTP did not support headers, so there was no reliable way to distinguish text from images. When HTTP 1.0 arrived, HTTP was no longer just used for transferring hypertext, but the name has stuck.

like image 37
Dietrich Epp Avatar answered Sep 20 '22 12:09

Dietrich Epp