Gin: No way to change POST max size

Created on 28 Nov 2014  ·  3Comments  ·  Source: gin-gonic/gin

In the http module usually you can do:

req.Body = http.MaxBytesReader(rw, req.Body, 5 << 20)

and have a byte limit on POST request as big as you want. In gin there is no Body so it is very hard to change these settings.

Is there a workaround? Can you implement a POST max size limit configuration?

Most helpful comment

I've done:

c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, size)

And it has worked.

All 3 comments

I've done:

c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, size)

And it has worked.

Will give it a try, thanks.

I think you have the Context just after the POST is submitted but it is not submitted if the size is bigger than the limit. Your approach works to decrease the size but not to increase it apparently. I guess the Context is callable inside the request only.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sofish picture sofish  ·  3Comments

ccaza picture ccaza  ·  3Comments

lilee picture lilee  ·  3Comments

ghost picture ghost  ·  3Comments

Bloomca picture Bloomca  ·  3Comments