August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this subsection, you will learn how to time out a connection on the server side. You need to do this because there are times when clients take much longer than expected to end an HTTP connection. This usually happens for two reasons. The first reason is bugs in the client software, and the second reason is when a server process is experiencing an attack!
This technique is going to be implemented in the serverTimeOut.go source code file, which will be presented in four parts. The first part of serverTimeOut.go is as follows:
package main import ( "fmt" "net/http" "os" "time" ) func myHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Serving: %s\n", r.URL.Path) fmt.Printf("Served: ...Read now
Unlock full access