Good to know – HTTP Protocol

When tinkering with OData, as well as SAC i’m reminded of the good-old-days of web-development, POST and GET requests, AJAX and service workers: What sounds like a toilet cleaner and a waiter in the restaurant, actually it’s all about the early days of asynchronous web-development and webapps. – Time to have closer look at the prime father of the world wide web and the protocol of all protocols: HTTP.

HTTP is the abbreviation of Hypertext Transfer Protocol and an “application-level protocol for distributed, collaborative, hypermedia information systems. It is a generic, stateless, protocol which can be used for many tasks beyond its use for hypertext, such as name servers and distributed object management systems, through extension of its request methods, error codes and headers.” (Quote from https://datatracker.ietf.org/doc/html/rfc2616). developer.mozilla.org – Evolution of HTTP gives an overview of the ecolution from HTTP/0.9 around 1989 to HTTP/3 (based on UDP) in 2022. For a quick overview on the versions see Youtube – HTTP, Youtube – Everything You Need to Know About QUIC and HTTP3.

Key aspects of the protocol:
– generic & simple
– stateless
– extensible

But what does this actually mean for designing applications and using APIs:
– generic & simple
It’s human-readable and can be inspected in plain-text. Requests can be fired by a variety of tools (see the tools section) – starting with a (quiet obvious) web-browser. For the more shell-savy tools like curl come in handy. The result is presented instantly. It’s language agnostic – that’s why you can tinker with it just in the browser. Real-life lessons learned: use http-client tools and install browser-extensions for an optimized presentation. The Firefox/Chrome developer-tools are not to be scoffed at.
– stateless
“There is no link between two requests being successively carried out on the same connection.” (Quote) This needs to be implemented by workarounds like cookies. OData has a neat feature btw for Draft-Handling.
– extensible
“New functionality can even be introduced by a simple agreement between a client and a server about a new header’s semantics.” This could eg. include enhanced security by adding authentication or caching (see Mozilla – Headers). This is also what facilitated the evolution up to the state-of-the-art HTTP/3

Usage
– classical Web
Mozilla – HTTP Request methods

– OData
https://blog.daniel-purucker.com/odata-and-sap/
https://blog.daniel-purucker.com/odata-by-example/

– CORS
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
help.sap.com – CORS

Examples
Postman-Examples: Postman – Sending requests
Example REST API: https://reqres.in/
For OData see my repository: https://github.com/dapuru/odata

Resources:
Mozilla – Basics of HTTP
Youtube – Evolution of HTTP
Youtube – Everything You Need to Know About QUIC and HTTP3

Tools:
classical curl
httpie – as an alternative to curl
Postman – http client
HTTPToolkit Debugger
Hosted example REST API

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.