Menu

1 / 4

Why Apache returned 502 for our Go uploads

DEV Community: go·RadarMakers·6 days ago
#Wqbwlcd4
#devtogo#devto#dev#body#handler
Reading 0:00
15s threshold

An oversized upload should give someone a useful rejection. In our case, the browser received "Upload failed: 502" even though the Go handler had a file-too-large response. The affected site was RadarMakers , a free launch platform for indie makers, with Apache forwarding uploads to Go.

The interesting part was the difference between the application response and the response that reached the browser. The workaround checks the declared request length before parsing multipart data, attempts a bounded discard of an oversized body, then writes the rejection.

This account comes from the current handler and its Git history. The earlier failure is documented there; I have not reproduced it for this article. The code explains a specific workaround, with limits that matter as much as the happy path.

What the proxy changed

The failure was not simply that the application rejected a large file. The browser saw a 502 from Apache when the Go server reset the connection while the proxy was still forwarding the body.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.