Home / Companies / Cloudflare / Blog / Post Details
Content Deep Dive

The complete guide to Go net/http timeouts

Blog post from Cloudflare

Post Details
Company
Date Published
Author
Filippo Valsorda
Word Count
1,552
Language
English
Hacker News Points
12
Summary

This article discusses timeouts when writing an HTTP server or client in Go. It explains the concept of Deadlines and how they can be used to implement timeouts on both the server and client side. The author also covers server timeouts, including ReadTimeout and WriteTimeout, as well as client-side timeouts such as Timeout field of http.Client, net.Dialer.Timeout, http.Transport.TLSHandshakeTimeout, and others. Additionally, it touches on how to cancel a request using Request.Cancel or Context in Go 1.7. The article emphasizes the importance of setting timeouts to prevent resource leaks and getting stuck during network operations.