Skip to content

Commit d8862bd

Browse files
authored
Changes for use of proxy-wasm in envoy-wasm. (proxy-wasm#11)
Signed-off-by: John Plevyak <jplevyak@gmail.com> * Fix test. Signed-off-by: John Plevyak <jplevyak@gmail.com> * Remove overflow. Signed-off-by: John Plevyak <jplevyak@gmail.com>
1 parent b6f17d0 commit d8862bd

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

proxy_wasm_api.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,14 @@ inline WasmResult getBufferStatus(WasmBufferType type, size_t *size, uint32_t *f
746746
return proxy_get_buffer_status(type, size, flags);
747747
}
748748

749+
inline WasmResult setBuffer(WasmBufferType type, size_t start, size_t length, StringView data,
750+
size_t *new_size = nullptr) {
751+
auto result = proxy_set_buffer_bytes(type, start, length, data.data(), data.size());
752+
if (result == WasmResult::Ok && new_size)
753+
*new_size = *new_size - length + data.size();
754+
return result;
755+
}
756+
749757
// HTTP
750758

751759
inline void MakeHeaderStringPairsBuffer(const HeaderStringPairs &headers, void **buffer_ptr,

proxy_wasm_externs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ extern "C" WasmResult proxy_get_buffer_bytes(WasmBufferType type, uint32_t start
112112
const char **ptr, size_t *size);
113113
extern "C" WasmResult proxy_get_buffer_status(WasmBufferType type, size_t *length_ptr,
114114
uint32_t *flags_ptr);
115+
extern "C" WasmResult proxy_set_buffer_bytes(WasmBufferType type, uint32_t start, uint32_t length,
116+
const char *ptr, size_t size);
115117

116118
// HTTP
117119
extern "C" WasmResult proxy_http_call(const char *uri_ptr, size_t uri_size, void *header_pairs_ptr,
@@ -175,8 +177,6 @@ extern "C" FilterMetadataStatus proxy_on_response_metadata(uint32_t context_id,
175177
// HTTP/gRPC.
176178
extern "C" void proxy_on_http_call_response(uint32_t context_id, uint32_t token, uint32_t headers,
177179
uint32_t body_size, uint32_t trailers);
178-
extern "C" void proxy_on_grpc_create_initial_metadata(uint32_t context_id, uint32_t token,
179-
uint32_t headers);
180180
extern "C" void proxy_on_grpc_receive_initial_metadata(uint32_t context_id, uint32_t token,
181181
uint32_t headers);
182182
extern "C" void proxy_on_grpc_trailing_metadata(uint32_t context_id, uint32_t token,

proxy_wasm_intrinsics.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ mergeInto(LibraryManager.library, {
4040
proxy_remove_header_map_value: function () {},
4141
proxy_get_buffer_bytes: function () {},
4242
proxy_get_buffer_status: function () {},
43+
proxy_set_buffer_bytes: function () {},
4344
proxy_http_call: function () {},
4445
proxy_define_metric: function () {},
4546
proxy_increment_metric: function () {},

0 commit comments

Comments
 (0)