Skip to content

Commit

Permalink
Webservice: Return 413 when requesting too large image.
Browse files Browse the repository at this point in the history
  • Loading branch information
michiwend committed Jan 17, 2016
1 parent 9547559 commit 8ec86e1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions service/placeholder.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ func serveImage(w http.ResponseWriter, r *http.Request) {
text := r.FormValue("text")

if width > 4000 || height > 4000 {
w.Header().Set("Content-Type", "text/html")
w.Write([]byte("image too large"))
http.Error(w, "Image too large", http.StatusRequestEntityTooLarge)
log.WithFields(log.Fields{
"width": width,
"height": height,
}).Warn("requested image too large")
return
}

foregroundValue := r.FormValue("fg")
backgroundValue := r.FormValue("bg")
Expand Down

0 comments on commit 8ec86e1

Please sign in to comment.