• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-server / 2035203102

11 Sep 2025 07:37PM UTC coverage: 65.606% (+0.3%) from 65.283%
2035203102

Pull #959

gitlab-ci

mzedel
fix(gui): let users know about billing related issues

- to e.g. help identify rate limiting failures

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #959: fix(gui): let users know about billing related issues

28607 of 43604 relevant lines covered (65.61%)

1.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.59
/backend/pkg/requestsize/middleware.go
1
package requestsize
2

3
import (
4
        "net/http"
5

6
        "github.com/gin-gonic/gin"
7

8
        "github.com/mendersoftware/mender-server/pkg/rest.utils"
9
)
10

11
func Middleware(size int64) gin.HandlerFunc {
7✔
12
        if size < 0 {
7✔
13
                panic("requestsize Middleware initialized with negativ size")
×
14
        }
15
        tooLargeErr := http.MaxBytesError{
7✔
16
                Limit: size,
7✔
17
        }
7✔
18
        return func(c *gin.Context) {
14✔
19
                // if the Content-Length in header and is greater than size limit
7✔
20
                if c.Request.ContentLength > int64(size) {
7✔
21
                        rest.RenderError(c, http.StatusRequestEntityTooLarge, &tooLargeErr)
×
22
                        c.Abort()
×
23
                        return
×
24
                }
×
25
                // wrapping a nil body with MaxBytesReader causes a nil pointer dereference panic
26
                // when calling c.ShouldBindJSON()
27
                if c.Request.Body != nil {
14✔
28
                        c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, size)
7✔
29
                }
7✔
30

31
                c.Next()
7✔
32
        }
33
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc