Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ func newClientConfig(rawURL string, options []ClientOption) (*clientConfig, *Err
Procedure: protoPath,
CompressionPools: make(map[string]*compressionPool),
BufferPool: newBufferPool(),
ReadMaxBytes: defaultReadMaxBytes,
}
withProtoBinaryCodec().applyToClient(&config)
withGzip().applyToClient(&config)
Expand Down
6 changes: 3 additions & 3 deletions connect_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ func TestServer(t *testing.T) {
if testing.Short() {
t.Skipf("skipping %s test in short mode", t.Name())
}
hellos := strings.Repeat("hello", 1024*1024) // ~5mb
hellos := strings.Repeat("hello", 512*1024) // ~2.5mb
request := connect.NewRequest(&pingv1.PingRequest{Text: hellos})
for _, el := range expectedHeaderValues {
request.Header().Add(clientHeader, el)
Expand Down Expand Up @@ -1686,7 +1686,7 @@ func TestClientWithReadMaxBytes(t *testing.T) {
} else {
compressionOption = connect.WithCompressMinBytes(math.MaxInt)
}
mux.Handle(pingv1connect.NewPingServiceHandler(pingServer{}, compressionOption))
mux.Handle(pingv1connect.NewPingServiceHandler(pingServer{}, compressionOption, connect.WithReadMaxBytes(0)))
server := memhttptest.NewServer(t, mux)
return server
}
Expand Down Expand Up @@ -1822,7 +1822,7 @@ func TestHandlerWithSendMaxBytes(t *testing.T) {
newHTTP2Server := func(t *testing.T, compressed bool, sendMaxBytes int) *memhttp.Server {
t.Helper()
mux := http.NewServeMux()
options := []connect.HandlerOption{connect.WithSendMaxBytes(sendMaxBytes)}
options := []connect.HandlerOption{connect.WithSendMaxBytes(sendMaxBytes), connect.WithReadMaxBytes(0)}
if compressed {
options = append(options, connect.WithCompressMinBytes(1))
} else {
Expand Down
1 change: 1 addition & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ func newHandlerConfig(procedure string, streamType StreamType, options []Handler
CompressionPools: make(map[string]*compressionPool),
Codecs: make(map[string]Codec),
BufferPool: newBufferPool(),
ReadMaxBytes: defaultReadMaxBytes,
StreamType: streamType,
}
withProtoBinaryCodec().applyToHandler(&config)
Expand Down
4 changes: 2 additions & 2 deletions option.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ func WithCompressMinBytes(minBytes int) Option {
// size of a message that the server can respond with. Limits apply to each Protobuf
// message, not to the stream as a whole.
//
// Setting WithReadMaxBytes to zero allows any message size. Both clients and
// handlers default to allowing any request size.
// Both clients and handlers default to a limit of 4 MiB. Setting
// WithReadMaxBytes to zero allows any message size.
//
// Handlers may also use [http.MaxBytesHandler] to limit the total size of the
// HTTP request stream (rather than the per-message size). Connect handles
Expand Down
2 changes: 2 additions & 0 deletions protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const (
headerDate = "Date"

discardLimit = 1024 * 1024 * 4 // 4MiB

defaultReadMaxBytes = 1024 * 1024 * 4 // 4MiB
)

var errNoTimeout = errors.New("no timeout")
Expand Down
Loading