PHPNews

425 Too Early

When a HTTP client makes a connection to a HTTPS server, it uses TLS to create a secure connection. TLS can have a bit of a complicated ‘handshake’ to establish the connection. Because there’s a bunch of back and forward, this can take a long time, especially when there’s a lot of latency between server and client. …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday May 14, 2019


424 Failed Dependency

The 424 Failed Dependency status-code does not appear in the base HTTP specification, but is part of WebDAV specification , which is an extension to HTTP. WebDAV has a concept of ‘properties’ that are associated with resources. They are a little bit like extended file attributes , which is a feature on many …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday May 7, 2019


423 Locked

The 423 Locked status-code does not appear in the base HTTP specification, but is part of WebDAV specification , which is an extension to HTTP. A major goal of WebDAV was to provide a ‘filesystem over the web’. One of its core features is for users to ‘lock’ specific files and directories to prevent others …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday April 30, 2019


422 Unprocessable Entity

The 422 Unprocessable Entity status-code does not appear in the base HTTP specification. Like 102 and 207 it’s part of the WebDAV specification , which is an extension to HTTP. Unlike the other two, the 422 code has a good general use-case, and is often used in Web API’s. The 422 code implies that …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday April 23, 2019


421 Misdirected Request

A server should emit 421 Misdirected Request when it receives a HTTP request that was not intended for that server. This status was introduced with HTTP/2, but it may also be applicable to HTTP/1 servers. For example, a server might receive the following HTTP request: GET /contact.html HTTP/1.1 Host: …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday April 16, 2019


420 Enhance your calm

The 420 Enhance Your Calm status code is an unofficial extension by Twitter. Twitter used this to tell HTTP clients that they were being rate limited. Rate limiting means putting restrictions on the total number of requests a client may do within a time period. For Twitter it was useful enough to extend the …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday April 9, 2019


418 I'm a teapot

The IETF has a tradition to publish one or more april-fools RFC documents every year. Among the most famous are IP over Avian Carriers with Quality of Service , and of course Hyper Text Coffee Pot Control Protocol , which introduced the 418 I'm a teapot HTTP status. This status-code is of course not an …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday April 2, 2019


Using loops instead of higher order functions

I came across a great article from Kirstian Poslek, titled “One reduce() to rule them all” . It explains the reduce() function quite well. I often feel though that using higher order functions are used in many cases where simple loops might be more legible. The article ends with an example of a function that …

Continue reading »

Written by Evert Pot - - Aggregated on Thursday March 28, 2019


417 Expectation Failed

A server emits 417 Expecation Failed when it encountered a Expect header that it didn’t understand or doesn’t support. A client can use the Expect header to tell the server that it requires a certain behavior from a server. The only expectation that (as far as I know) is standardized, is 100-continue . …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday March 26, 2019


416 Range Not Satisfiable

It’s possible for a client to request partial responses from a server. For example, a client might only want the first 5 minutes of a video, or the last 100 lines of a log file. HTTP clients and servers can do this with range requests. For example, this request asks for the first 100 bytes: GET /foo.md …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday March 19, 2019


An OAuth2 middleware for fetch()

I was a bit frustrated with the existing offerings for OAuth2 clients in Javascript. I heavily use the Fetch API directly, but Web API’s haven’t really caught up to have deep integration with OAuth2. We were using client-oauth2 , but the minified size of this library was close to 40kb which ended up being a …

Continue reading »

Written by Evert Pot - - Aggregated on Thursday March 14, 2019


415 Unsupported Media Type

When a server receives a request with a body it doesn’t understand, it should return 415 Unsupported Media Type . Most commonly this is a good response for for example a POST or PUT request with an unknown Content-Type header. The specification says that aside from inspecting the Content-Type header, …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday March 12, 2019


414 URI Too Long

The URI or path of a HTTP request doesn’t have any hard limits in terms of how long it’s allowed to be. However, Browsers and search engines have limits , and on the server side it’s a good idea to limit the length of the URI to combat certain denial-of-service attacks or bugs. Based on limits of browsers, it’s …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday March 5, 2019


413 Payload Too Large

The 413 Payload Too Large response is used when the client sent a request with a body that’s too big. Maybe the request was a file upload, and it exceeded the maximum file-size, or maybe it’s an API and it preemptively blocks requests that are unrealisticly large. It’s a good idea to try and think of …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday February 26, 2019


412 Precondition Failed

In HTTP it’s possible to do conditional requests. These are requests that only execute if the right conditions are met. For GET requests, this might be done to only retrieve the resource if it has changed. For those cases 304 Not Modified is returned. For other cases, 412 Precondition Failed is returned. …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday February 19, 2019


411 Length Required

Most HTTP requests that have a request body, will also have a Content-Length header indicating how big the body will be. However, this is optional for some cases, such as when Chunked Transfer Coding is used. It’s useful for a client to not include a Content-Length header for a few different cases. For …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday February 12, 2019


410 Gone

410 Gone is a status code that can be used in cases where a resource is gone and never coming back. It’s a more specific version of 404 Not Found . A good example for using 410 instead of 404 is when a resource was intentionally removed. Using 410 can be helpful, because it signals to other people …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday February 5, 2019


Ketting 2.5 release.

Ketting is an attempt at making a generic Hypermedia API client for javascript. It uses a ‘link’ and following links as the most important primitive. Last week I released version 2.5.0 on NPM so maybe it’s time to list some of the improvements since the last update in order from most to least interesting. …

Continue reading »

Written by Evert Pot - - Aggregated on Wednesday January 30, 2019


409 Conflict

409 Conflict is used in cases where the HTTP request was valid, but the current state of the server prevents it from being executed. This is useful for APIs. A few hypothetical examples: A user wants to add a file to a folder, but the folder doesn’t exist yet. Amazon S3 uses it when you try to delete a …

Continue reading »

Written by Evert Pot - - Aggregated on Tuesday January 29, 2019


bigint-money: an NPM package for doing currency math

Not long ago, I was confused about doing math with money and floating point issues. After a bunch of research and help from friends I figured out what many already did before me: Using floating points is indeed bad. You can get rounding issues and really want to use ‘precise math’. After that, I realized I wanted …

Continue reading »

Written by Evert Pot - - Aggregated on Wednesday January 23, 2019