Skip to content

Commit c7c1698

Browse files
committed
maxRequestSize
1 parent e728eef commit c7c1698

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Run <code><strong>src login <i>SOURCEGRAPH-URL</i></strong></code> to authentica
119119

120120
- `SRC_ENDPOINT`: the URL to your Sourcegraph instance (such as `https://sourcegraph.example.com`)
121121
- `SRC_ACCESS_TOKEN`: your Sourcegraph access token (on your Sourcegraph instance, click your user menu in the top right, then select **Settings > Access tokens** to create one)
122-
- `SRC_MAX_FILESIZE_MB`: maximum request body size in MB for git operations (default: 10)
122+
- `SRC_MAX_REQUESTSIZE_MB`: maximum request body size in MB for git operations (default: 10)
123123

124124
For convenience, you can add these environment variables persistently.
125125

internal/servegit/gitservice.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919

2020
const defaultMaxFileSizeMB = 10
2121

22-
func maxFileSize() int64 {
23-
if v := os.Getenv("SRC_MAX_FILESIZE_MB"); v != "" {
22+
func maxRequestSize() int64 {
23+
if v := os.Getenv("SRC_MAX_REQUESTSIZE_MB"); v != "" {
2424
if mb, err := strconv.ParseInt(v, 10, 64); err == nil && mb > 0 {
2525
return mb * 1024 * 1024
2626
}
@@ -120,7 +120,7 @@ func (s *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
120120
return
121121
}
122122

123-
body := r.Body
123+
body := io.NopCloser(io.LimitReader(r.Body, maxRequestSize()))
124124
defer body.Close()
125125

126126
if r.Header.Get("Content-Encoding") == "gzip" {
@@ -131,7 +131,7 @@ func (s *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
131131
}
132132
defer gzipReader.Close()
133133

134-
body = io.NopCloser(io.LimitReader(gzipReader, maxFileSize()))
134+
body = io.NopCloser(io.LimitReader(gzipReader, maxRequestSize()))
135135
}
136136

137137
// err is set if we fail to run command or have an unexpected svc. It is

0 commit comments

Comments
 (0)