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?
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.
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.
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.
There are two types of HTTP messages, requests and responses, each with its own format.
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:
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!).
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With