Created
August 15, 2019 00:19
-
-
Save Ameobea/aa67dfe5c6e2167a8fef9afda3f27b0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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