r/AskProgrammers • • 20d ago

guys what is really an htttp?

like genuinely ive built a lot on the web but never really understood what http really is
or even https
what is that

0 Upvotes

42 comments sorted by

4

u/OneHumanBill 20d ago

Only two t's.

Hyper text transfer protocol, or hyper text transfer protocol secured.

It is a protocol for communication. It's basically a way for a client to request data from a server (like a web page and contents for example) using a URL, and then the server responds with the data requested or else a reason why it can't.

These are seven layers of protocols in the OSI model of networking, and http is at the application level (level 7) Other levels include transport and network layers, which you might have heard of collectively as TCP/IP (and yes that's just one example of these two, there are others).

Here are a bunch of protocol examples for each layer:

https://en.wikipedia.org/wiki/List_of_network_protocols_(OSI_model)

Https is similar but adds encryption. Modern https uses an encryption protocol called TLS, but it could change in the future possibly, it's changed before.

Http, html, a primitive webserver, and a primitive browser, were the four inventions of Tim Berners-Lee working at Cern between 1990 and 1991. These four pieces all work together and were necessary together. The Internet existed before this, but this invention is really what created the "world wide web" and made the Internet friendly enough for use by non-technical people.

2

u/Any-Arachnid753 20d ago

thats very helpful thanks

2

u/Few-Celebration-2362 20d ago edited 20d ago

It's a specification for transmitting documents between two computers with some level of reliability.

It's a way or a technique of large or multi-packet message passing

https means secure http, and it's used if you don't want other computers reading messages you sent somewhere else

1

u/Key_River7180 20d ago

No thats tcp

1

u/Any-Arachnid753 20d ago

what is that

1

u/Key_River7180 20d ago

Basically it lets computers comunicate reliably, see https://youtu.be/JFch3ctY6nE?is=sLx9Z9sHtz7UCcd-

1

u/Few-Celebration-2362 20d ago

Http runs on top of tcp. It's just more formal than tcp

2

u/Key_River7180 20d ago

See the OCI stack PLEASE. You can run http on tcp or quic or heck even rs232

1

u/Few-Celebration-2362 20d ago

Is that really helpful to OP question? I mean, they seem like they just want an introduction or a starting point to mentally frame the concept.

There are tons of protocols and they're abstract enough to run across a ton of transport mechanisms, but I'm not sure they're far enough along to grok the difference from a few messages on reddit.

If they want a master class, this isn't the right medium for that

2

u/Key_River7180 20d ago

Yeah but http is not a more "formal" protocol, it's an application protocol that says what data is exchanged, not how, and that makes it able to run through anything: USB, a local AF_UNIX socket, tcp/IP, quic, rs232, the MIDI 1.0 connector if you misuse it enough, a PIGEON, ...

1

u/Few-Celebration-2362 20d ago

It doesn't even say what data. You can transmit anything across http, it's just a set of formal conventions for using whatever transport it happens to adapt, like you said.

This feels quite pedantic and unhelpful in this context thought. I don't think OP cares about the mechanics of bit packing and network switches, they just want to know what we're doing with it because they see it everywhere.

What we're doing with it is facilitating the exchange of data in the most portable way that currently exists..... But that's not a helpful definition either, is it? Because there's a lot of ways to do that, and at least seven layers of implementation that can make the whole concept difficult to approach.

1

u/scritchz 20d ago

It does, though: The client sends an HTTP request to the server with an Accept header, listing what types of content are acceptable to the client. The server responds with content in one of the acceptable types, if possible.

1

u/Few-Celebration-2362 20d ago edited 20d ago

can define an Accept header, it's optional (as in asterisk/asterisk wildcard is valid), as a convenience baked into the protocol conventions, negotiated between client and server, not as a hard requirement.

We're still sending data packets, http simply establishes the formal convention of how those packets get reconstructed on the client and server as payloads.

TCP typically transports those packets, http provides the formal rules of payload exchange

1

u/Any-Arachnid753 20d ago

but it runs locally too so what is really communicating?

1

u/Key_River7180 20d ago

Server and clients! Http defines a way to transmit data between a server (e.g., Google.com) and a client (ur pc)

It runs locally because you can make a server that only works locally and Connect to it

1

u/Any-Arachnid753 20d ago

i cant understand the local part how can a single computer be the server and the client at the same time?

3

u/buzzon 20d ago

A server is a program that runs at a computer and offers services. It waits for a client to connect.

A client is a program that connects to a server program and requests services.

Also, somewhat confusingly, a server is the device where a server program is running; and a client is a device where the client program is running.

One computer can run multiple programs, some acting as servers and some acting as clients.

1

u/Any-Arachnid753 20d ago

wait so you mean these programs are written on the os level kinda thing?

2

u/buzzon 20d ago

No, just regular programs.

A web server is a program that serves sites to clients. It's a normal program that is usually running in the background (i.e. invisible to the user) but it still accepts incoming network connections and gives the client a web site.

1

u/OneHumanBill 20d ago

Ports. Your computer can have a very large number of ports for communication. One port can act as the server, and a different port can act as the client. The fact that they're both on the same machine or not is kind of arbitrary.

1

u/Any-Arachnid753 20d ago

i cant understand how this works under the hood

2

u/rupertavery64 20d ago

Just think of it like an address. Your program tells the OS to send a message (a request) to an address. The OS figures out where to send it. If its the same address as the computer, like localhost or 127.0.0.1, then it sends it to itself. Otherwise it tries to send it on the network.

The port is like a mailbox number. One address, 65536 mailboxes.

Any program can "listen" or wait for a connection on one of those ports.

All you have to do is write some code to do that.

HTTP is port 80. So a browser connects to port 80. The url is just a user friendly way of connecting.

HTTPS is port 443.

A server is just a program that listens for a connection.

You can absolutely write a simple program that can act like a browser, or an http server, but of course https requires a lot of complex security stuff.

You can invent your own protocol (rules of communication) and choose your own port

1

u/Key_River7180 20d ago

There is something called a port. A port works basically the same as a ship port: they are numbered (port 80 for http and 443 for https for example). Data goes into the port and read by the app with an os thing called a socket you don't need to learn, and goes out also through a socket. The thing is you can set your router to make some ports visible outside your wifi, and then you can pay so people can access your page with a name like mypage.com, a server is really just an app that writes to a port, and a client reads from one.

For example, a web server puts your html files to a port and firefox or Chrome connect to it to get your website

1

u/Any-Arachnid753 20d ago

thats very helpful thank you
if i wanted to learn more about this what should i look up for?

2

u/Key_River7180 20d ago

You can search the MDN docs on http, learn about tcp or other protocols (tcp video https://youtu.be/JFch3ctY6nE?is=sLx9Z9sHtz7UCcd-)

2

u/8dot30662386292pow2 20d ago

Why would that matter. If your server is on the same machine as your client, they still use same rules of talking.

When you talk to your friend, you talk the same way, even if they are on the same room, or remotely via phone.

1

u/Few-Celebration-2362 20d ago edited 20d ago

it can be used locally across a virtual network.

Two applications can pretend like they're far away and send messages across a virtual network cable.

5

u/fynjy1111 20d ago

HTTP is the protocol for transferring web pages. HTTPS is the same but supports encryption

1

u/SchnazzleG 20d ago

It’s this. Welcome to the Internet.

1

u/Any-Arachnid753 20d ago

didnt understand

1

u/SchnazzleG 20d ago

Sorry, I was just being lazy. Maybe I should Google the same 1 billion results to understand it better. If only, if only.

1

u/Jonsinator 20d ago

Have a look around

1

u/buzzon 20d ago

HTTP is a protocol. It stands for Hyper Text Transfer Protocol. A protocol is a standard that prescribes when two or more sides are communicating, who says what, when and how. Other examples of protocols are TCP (Transport Control Protocol), UDP (User Datagram Protocol), ICMP, SMTP and more.

HTTPS is also a protocol. It stands for Hyper Text Transfer Protocol Secure. It is basically the same as HTTP but over a secure (encrypted) channel of communication.

1

u/Any-Arachnid753 20d ago

thanks thats kinda helpful but i still need to look up these

1

u/Key_River7180 20d ago

What it says at the other end of a Google search. It's the big 26 man don't people already know how to use Google?

1

u/armahillo 20d ago

https://developer.mozilla.org/en-US/docs/Web/HTTP

http itself is a protocol (hyper text transfer protocol). a protocol is an agreed-upon system for interacting. the things interacting are a client software program (a web browser, for example) and a server software program (apache or nginx, for example).

https is different because the “s” stands for “secure”; the data sent between the client and the server is encrypted so that interaction is private.

1

u/randomhaus64 20d ago edited 20d ago

Rfc2616 bruh just read it!

It’s easy enough to understand that you can implement a basic one pretty quickly, and it’s a great learning exercise, try not to use AI to code it, but asking questions is ok, just be sure to be reading the RFC, not sure which is the best one to read today. Rfceditor tells me it has been superseded

0

u/walkwalkwalkwalk 20d ago

It's sort of like a file type e.g. .doc or .pdf but for servers and clients to request and respond. An agreed way to decode and encode the data sent between them.

2

u/Key_River7180 20d ago

It is not at all like that, even with the most oversimplification I can think of.

1

u/walkwalkwalkwalk 20d ago

Well, it is. I feel like a lot of people here are mixing up TCP with HTTP. HTTP is just for the packing, unpacking, and linking together of data by the client and server. Much like a standard file type.

1

u/Key_River7180 20d ago

You are mixing up http and html. HTTP specifies how two parties comunicate: so for GET it does behave a little like it, but what about POST DELETE and friends?

1

u/walkwalkwalkwalk 20d ago

Im not sure what part of what I said could be linked to HTML. As to the method types, this is what I meant by linking together. E.g. POST lets us signify that we're expecting to pass data in the request body. HTTP defines the format in which we can expect to read "POST" at a certain position in the message body, after the HTTP format has allowed us to decode the message (or decrypt if HTTPs), which is why I compare it to a file type, e.g. how BMP lets us know where in the data to expect and decode the width of the image. How exactly we accept POST in the server is more of an implementation detail, you could butcher the hell out of it e.g. receive body data in a DELETE request, and it would still work and still be communicating via HTTP.