Skip to content

Instantly share code, notes, and snippets.

@Ameobea
Created August 15, 2019 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ameobea/aa67dfe5c6e2167a8fef9afda3f27b0b to your computer and use it in GitHub Desktop.
Save Ameobea/aa67dfe5c6e2167a8fef9afda3f27b0b to your computer and use it in GitHub Desktop.
FROM golang:1.12.3-stretch
ADD . /app
WORKDIR /app
RUN go build -o cloud-run-header-limit-demo .
RUN cp cloud-run-header-limit-demo /usr/local/bin/
CMD ["/usr/local/bin/cloud-run-header-limit-demo"]
package main
import (
"fmt"
"net/http"
"os"
)
func handleIndex(resWriter http.ResponseWriter, req *http.Request) {
longString := ""
for i := 0; i < 10000; i++ {
longString += "-"
}
// Set a very large header
resWriter.Header().Set("X-Very-Large-Header", longString)
fmt.Fprint(resWriter, "OK")
}
func main() {
http.HandleFunc("/", handleIndex)
var port = os.Getenv("PORT")
if len(port) == 0 {
port = "4565"
}
err := http.ListenAndServe(":"+port, nil)
if err != nil {
fmt.Println("Error listening on port", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment