Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 37249c9

Browse files
author
Wim Spaargaren
committed
chore: correction setting request and response body
1 parent 0190532 commit 37249c9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

proxywasm/hostcall.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,10 @@ func GetHttpRequestBody(start, maxSize int) ([]byte, error) {
129129
}
130130

131131
func SetHttpRequestBody(body []byte) error {
132-
if len(body) == 0 {
133-
st := rawhostcall.ProxySetBufferBytes(types.BufferTypeHttpRequestBody, 0, len(body), nil, len(body))
134-
return types.StatusToError(st)
132+
var bufferData *byte
133+
if len(body) != 0 {
134+
bufferData = &body[0]
135135
}
136-
bufferData := &body[0]
137136
st := rawhostcall.ProxySetBufferBytes(types.BufferTypeHttpRequestBody, 0, len(body), bufferData, len(body))
138137
return types.StatusToError(st)
139138
}
@@ -200,11 +199,10 @@ func GetHttpResponseBody(start, maxSize int) ([]byte, error) {
200199
}
201200

202201
func SetHttpResponseBody(body []byte) error {
203-
if len(body) == 0 {
204-
st := rawhostcall.ProxySetBufferBytes(types.BufferTypeHttpRequestBody, 0, len(body), nil, len(body))
205-
return types.StatusToError(st)
202+
var bufferData *byte
203+
if len(body) != 0 {
204+
bufferData = &body[0]
206205
}
207-
bufferData := &body[0]
208206
st := rawhostcall.ProxySetBufferBytes(types.BufferTypeHttpResponseBody, 0, len(body), bufferData, len(body))
209207
return types.StatusToError(st)
210208
}

0 commit comments

Comments
 (0)