Skip to content

Instantly share code, notes, and snippets.

@nonlogos
Created November 13, 2017 23:10
Show Gist options
  • Save nonlogos/b2f79644c6c7c016cf050273fcf1c41b to your computer and use it in GitHub Desktop.
Save nonlogos/b2f79644c6c7c016cf050273fcf1c41b to your computer and use it in GitHub Desktop.
Web Protocols #general
# Clients
Clients are computer programs that connect to servers
initiate a connection
Any computer can be a client
# hypertext transfer protocol
how web servers and web browsers communicate
# HTTP verbs
HTTP requests begin with a VERB.
here are somethings each VERB is used for:
* GET - fetch a document
* POST - submit a form / send data / or sometimes upload a file
* HEAD - fetch metadata about a document
* PUT - upload a file
* DELETE
* OPTIONS
# HTTP headers
Headers have a key followed by a colon followed by a value:
key: value
# Curl commands
curl -s <url> : get file from the url
curl -H : set http request header
curl -sI <url> : only get the http response header
curl -d : data
curl -X POST <url> -d ... : post data
Aside from servers and clients, there is a thrid role in computer networks: peer.
In a peer to peer network, clients establish connections directly to other clients.
Nodes in the network are symmetric with no fixed central servers (both are clients and servers at the same time)
Examples of peer to peer protocols:
* bittorrent
* webrtc
Each computer can have many services
A port is a number between 1 and 65535 that differentiates among the services on a system
# customary ports
* 21 - ftp (control port)
* 22 - ssh
* 25 - smtp
* 80 - http
* 443 - https
* 3306 - mysql
* 5432 - postgresql
* 5984 - couchdb
* 6667 - irc
# port and permissions
by default, systems can only listen to ports below 1024 as the root user
Sometimes when people say 'server' they mean a computer program that listens for incoming connections
Other times when people say 'server' they mean a computer that is configured to run server programs
Any computer that has a networking stack can be a server
# SSH is a binary protocol so we can't just
Example of network protocols
# HTTP: browse web pages
# HTTPS: browse web pages with encryption
# SMTP: sends and receives emails
# IMAP, POP3: loads emails from an inbox
# IRC: chat
# FTP: file transfer
# SSH: remote shell over an encrypted connection
# SSL: low-level secure data transfer (used by HTTPS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment