lancet
lancet copied to clipboard
HTTP methods do not have a way to set a timeout
Functions that make HTTP requests should accept context for cancellation. Even worse, an http client with default options is used. Not only it doesn't have any timeouts, creating a new HTTP client for every single request isn't efficient and would not utilise HTTP "keep alive" mechanics.
Functions that make HTTP requests should accept context for cancellation. Even worse, an http client with default options is used. Not only it doesn't have any timeouts, creating a new HTTP client for every single request isn't efficient and would not utilise HTTP "keep alive" mechanics.
@dobegor : Yeah, your point makes sense. I do have plan to refactor the http request functions in file netutil/http.go. Here is the solution:
- Add context param to exists functions(HttpGet, HttpPost, HttpPut, HttpDelete, HttpPatch). This will bring break changes compare to previous version.
- Create new function and redesign the logic of http request. Will support for common features. Eg. Timeout...
I prefer the second one.
Functions that make HTTP requests should accept context for cancellation. Even worse, an http client with default options is used. Not only it doesn't have any timeouts, creating a new HTTP client for every single request isn't efficient and would not utilise HTTP "keep alive" mechanics.
Redesign the logic of sending http request, refer to - http_client.go.