@@ -85,13 +85,14 @@ type Plugin struct {
8585 Timeout time.Duration
8686 Config map [string ]string
8787 // NOTE: maybe we can have some nice methods for getting/setting vars
88- Var map [string ][]byte
89- AllowedHosts []string
90- AllowedPaths map [string ]string
91- LastStatusCode int
92- log func (LogLevel , string )
93- logLevel LogLevel
94- guestRuntime guestRuntime
88+ Var map [string ][]byte
89+ AllowedHosts []string
90+ AllowedPaths map [string ]string
91+ LastStatusCode int
92+ MaxHttpResponseBytes int64
93+ log func (LogLevel , string )
94+ logLevel LogLevel
95+ guestRuntime guestRuntime
9596}
9697
9798func logStd (level LogLevel , message string ) {
@@ -220,7 +221,8 @@ func (u WasmUrl) ToWasmData(ctx context.Context) (WasmData, error) {
220221type Manifest struct {
221222 Wasm []Wasm `json:"wasm"`
222223 Memory struct {
223- MaxPages uint32 `json:"max_pages,omitempty"`
224+ MaxPages uint32 `json:"max_pages,omitempty"`
225+ MaxHttpResponseBytes uint64 `json:"max_http_response_bytes,omitempty"`
224226 } `json:"memory,omitempty"`
225227 Config map [string ]string `json:"config,omitempty"`
226228 AllowedHosts []string `json:"allowed_hosts,omitempty"`
@@ -231,7 +233,8 @@ type Manifest struct {
231233type concreteManifest struct {
232234 Wasm []concreteWasm `json:"wasm"`
233235 Memory struct {
234- MaxPages uint32 `json:"max_pages,omitempty"`
236+ MaxPages uint32 `json:"max_pages,omitempty"`
237+ MaxHttpResponseBytes uint64 `json:"max_http_response_bytes,omitempty"`
235238 } `json:"memory,omitempty"`
236239 Config map [string ]string `json:"config,omitempty"`
237240 AllowedHosts []string `json:"allowed_hosts,omitempty"`
@@ -415,20 +418,26 @@ func NewPlugin(
415418 }
416419
417420 i := 0
421+ httpMax := int64 (1024 * 1024 * 50 )
422+ if manifest .Memory .MaxHttpResponseBytes != 0 {
423+ httpMax = int64 (manifest .Memory .MaxHttpResponseBytes )
424+ }
418425 for _ , m := range modules {
419426 if m .Name () == "main" {
420427 p := & Plugin {
421- Runtime : & c ,
422- Modules : modules ,
423- Main : m ,
424- Config : manifest .Config ,
425- Var : map [string ][]byte {},
426- AllowedHosts : manifest .AllowedHosts ,
427- AllowedPaths : manifest .AllowedPaths ,
428- LastStatusCode : 0 ,
429- Timeout : time .Duration (manifest .Timeout ) * time .Millisecond ,
430- log : logStd ,
431- logLevel : logLevel }
428+ Runtime : & c ,
429+ Modules : modules ,
430+ Main : m ,
431+ Config : manifest .Config ,
432+ Var : map [string ][]byte {},
433+ AllowedHosts : manifest .AllowedHosts ,
434+ AllowedPaths : manifest .AllowedPaths ,
435+ LastStatusCode : 0 ,
436+ Timeout : time .Duration (manifest .Timeout ) * time .Millisecond ,
437+ MaxHttpResponseBytes : httpMax ,
438+ log : logStd ,
439+ logLevel : logLevel ,
440+ }
432441
433442 p .guestRuntime = detectGuestRuntime (p )
434443 return p , nil
0 commit comments