Tag: http

HTTP Request Body for Form Values

HTTP Request Header HTTP clients and servers largely depend on the “Content-Type” header to determine how to parse the request/response body. Common values for the “Content-Type” header are application/json application/atom+xml application/pdf application/octet-stream application/x-www-form-urlencoded and request/response body should be processed as JSON, XML, PDF, Raw Stream, or Form Data respectively. How is Form Data Sent? 99.99%…

Why HTTP Status in Response is always StatusOK?

Why the following code works as expected but the next one does not? Response 1 resp.WriteHeader(http.StatusBadRequest) _, _ = resp.Write([]byte(`status code is 400`)) But if we change the order and write the body first and header later: Response 2 _, _ = resp.Write([]byte(`status code is not 400!!`)) resp.WriteHeader(http.StatusBadRequest) The header is set to http.StatusOK in…

What is Special in HTTP 2.0?

Useful Points: Unlike text protocol HTTP/1.0 & HTTP/1.1, HTTP/2.0 is binary based protocol. So tools like curl are needed to make requests instead of plain telnet. The TCP connection is now multiplexed for multiple requests. So a client should open only one connection. Few browsers support HTTP/2.0 with only TLS. The compression of data is…

HTTP Accelerator Cache: Varnish

HTTP Accelerator Cache: Varnish The Varnish is an open-source reverse proxy server. Its primary purpose is to cache HTTP responses. Besides it also enables modifying HTTP requests/ response to the origin. The Varnish documentation highlights that the server is highly scalable on a multi-core system, efficient (uses mostly kernel services such as kqueue, epoll, memory…

Supershort Intro to TLS

Transport Layer Security Client & Server use a stateful connection over TCP The connection is secured using a symmetric encryption Client indicates to server to use TLS Client usually use a different port (e.g.443) A primary use of TLS is to secure World Wide Web traffic between a website and a web browser encoded with…

curl: (55) Failed sending HTTP POST request

Synopsis I got the curl: (55) Failed sending HTTP POST request error while trying to make a POST call to a pingable URL. The error is misleading. It does not inform about the error cause of the error. Solution Revisit the request carefully. Make sure that all headers are in proper syntax (Key: value) URL…

Dummies Guide to HTTP Cache Control

All modern browsers cache response for a request (HEAD/GET). Cache-Control is primarily meant for browser cache and how & where the server-side caches a response. Max Cache Time Browsers cache a response for the value of max-age response header If the response is expired, the browser can use the previous response Etag and re-request the…