diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/bindings/bindings.cpp | 21 | ||||
-rw-r--r-- | src/bun.js/bindings/bindings.zig | 2 | ||||
-rw-r--r-- | src/bun.js/bindings/headers-cpp.h | 2 | ||||
-rw-r--r-- | src/bun.js/bindings/headers.h | 2 |
4 files changed, 15 insertions, 12 deletions
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 69d836754..a7a8e8327 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -215,17 +215,20 @@ typedef struct PicoHTTPHeaders { WebCore::FetchHeaders* WebCore__FetchHeaders__createFromPicoHeaders_(JSC__JSGlobalObject* arg0, const void* arg1) { PicoHTTPHeaders pico_headers = *reinterpret_cast<const PicoHTTPHeaders*>(arg1); - Vector<KeyValuePair<String, String>> pairs; - pairs.reserveCapacity(pico_headers.len); - for (size_t i = 0; i < pico_headers.len; i++) { - WTF::String name = WTF::String(pico_headers.ptr[i].name, pico_headers.ptr[i].name_len); - WTF::String value = WTF::String(pico_headers.ptr[i].value, pico_headers.ptr[i].value_len); - pairs.uncheckedAppend(KeyValuePair<String, String>(name, value)); + RefPtr<WebCore::FetchHeaders> headers = adoptRef(*new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} })); + + if (pico_headers.len > 0) { + Vector<KeyValuePair<String, String>> pairs; + pairs.reserveCapacity(pico_headers.len); + for (size_t i = 0; i < pico_headers.len; i++) { + WTF::String name = WTF::String(pico_headers.ptr[i].name, pico_headers.ptr[i].name_len); + WTF::String value = WTF::String(pico_headers.ptr[i].value, pico_headers.ptr[i].value_len); + pairs.uncheckedAppend(KeyValuePair<String, String>(name, value)); + } + headers->fill(WebCore::FetchHeaders::Init(WTFMove(pairs))); + pairs.releaseBuffer(); } - RefPtr<WebCore::FetchHeaders> headers = adoptRef(*new WebCore::FetchHeaders({ WebCore::FetchHeaders::Guard::None, {} })); - headers->fill(WebCore::FetchHeaders::Init(WTFMove(pairs))); - pairs.releaseBuffer(); return headers.leakRef(); } WebCore::FetchHeaders* WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject* arg0, void* arg1) diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 0f5111d28..3a44491e4 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -563,7 +563,7 @@ pub const FetchHeaders = opaque { } const PicoHeaders = extern struct { - ptr: *const anyopaque, + ptr: ?*const anyopaque, len: usize, }; diff --git a/src/bun.js/bindings/headers-cpp.h b/src/bun.js/bindings/headers-cpp.h index fed6b41a7..15c6d7c1e 100644 --- a/src/bun.js/bindings/headers-cpp.h +++ b/src/bun.js/bindings/headers-cpp.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1656242004 +//-- AUTOGENERATED FILE -- 1656323590 // clang-format off #pragma once diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h index c7d0eafd6..810d1a7c4 100644 --- a/src/bun.js/bindings/headers.h +++ b/src/bun.js/bindings/headers.h @@ -1,5 +1,5 @@ // clang-format off -//-- AUTOGENERATED FILE -- 1656242004 +//-- AUTOGENERATED FILE -- 1656323590 #pragma once #include <stddef.h> |