ipfs / ipfs/kubo

Harden http.Serve() with sensible Timeouts

Open
#3,533 7 comments 0 reactions 0 assignees View on GitHub
exp/novice kind/enhancement topic/api topic/gateway topic/rpc-api
Dominant language
Go
Stars
17.1k
Forks
3.2k
Avg merge
3d 18h
Merged PRs (30d)
11

Description

#### Version information: master

#### Type: Enhancement

#### Priority: P4

#### Description:
Currently we do:

https://github.com/ipfs/go-ipfs/blob/67a1b3e1bfe9d05478f15068f31cc6868f12a74f/core/corehttp/corehttp.go#L83

But https://blog.gopheracademy.com/advent-2016/exposing-go-on-the-internet/ shows that it is better to initialize a Server object and set sensible timeouts:

![image](https://cloud.githubusercontent.com/assets/1027022/21422429/db5d5b38-c837-11e6-90bd-98ca4f34bad5.png)

Example:
```
srv := &http.Server{
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
Handler: serveMux,
}
```

(IdleTimeout is only in Go 1.8)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.