Postel's Law
This law says that if your server sends HTTP responses, it should format headers exactly per spec. But if your server receives an HTTP request with an uncommon header order or an unusual format, you should still process it rather than drop the connection, as long as you can interpret it safely.
This principle contributed to the Internet’s resilience, meaning that different implementations can communicate because each side strives to be compatible.
In software in general, think of file readers: a robust one can open not-quite-perfect files (e.g., a tolerant XML parser might recover from a minor error), whereas a strict one might refuse. Postel’s Law would encourage the former. However, it has caveats. Being too liberal can allow sloppy producers to proliferate, and in security contexts, accepting malformed input can be risky. Some argue that overly tolerant software can cause long-term interoperability problems because producers never fix their bugs if everyone tolerates them.
- When your system emits data or interacts with the outside world, adhere closely to protocols and standards.
- When receiving data, handle variations, minor errors, or deviations where possible. Don't crash or reject communication over minor issues.
- In modern times, overly liberal acceptance can sometimes mask errors, so this law is occasionally tempered with security considerations.