|
36 | 36 |
|
37 | 37 | using builtins::web::base64::valueToJSByteString;
|
38 | 38 | using builtins::web::blob::Blob;
|
39 |
| -using builtins::web::blob::BlobReader; |
40 | 39 | using builtins::web::dom_exception::DOMException;
|
41 | 40 |
|
42 | 41 | // We use the StarlingMonkey Headers implementation, despite it supporting features that we do
|
@@ -792,38 +791,22 @@ bool RequestOrResponse::extract_body(JSContext *cx, JS::HandleObject self,
|
792 | 791 | host_api::HostString host_type_str;
|
793 | 792 |
|
794 | 793 | if (Blob::is_instance(body_obj)) {
|
795 |
| - auto native_stream = NativeStreamSource::create(cx, body_obj, JS::UndefinedHandleValue, |
796 |
| - Blob::stream_pull, Blob::stream_cancel); |
797 |
| - if (!native_stream) { |
| 794 | + RootedValue stream(cx); |
| 795 | + if (!Blob::stream(cx, body_obj, &stream)) { |
798 | 796 | return false;
|
799 | 797 | }
|
800 | 798 |
|
801 |
| - JS::RootedObject source(cx, native_stream); |
802 |
| - if (!source) { |
803 |
| - return false; |
804 |
| - } |
805 |
| - |
806 |
| - auto readers = Blob::readers(body_obj); |
807 |
| - auto blob = Blob::blob(body_obj); |
808 |
| - auto span = std::span<uint8_t>(blob->begin(), blob->length()); |
809 |
| - |
810 |
| - if (!readers->put(source, BlobReader(span))) { |
811 |
| - return false; |
812 |
| - } |
813 |
| - |
814 |
| - JS::RootedObject stream(cx, NativeStreamSource::stream(native_stream)); |
815 |
| - if (!stream) { |
816 |
| - return false; |
817 |
| - } |
| 799 | + MOZ_ASSERT(stream.isObject()); |
| 800 | + JS_SetReservedSlot(self, static_cast<uint32_t>(RequestOrResponse::Slots::BodyStream), stream); |
818 | 801 |
|
819 |
| - JS_SetReservedSlot(self, static_cast<uint32_t>(RequestOrResponse::Slots::BodyStream), |
820 |
| - JS::ObjectValue(*stream)); |
| 802 | + // TODO: Set content-length header from known body extracted size |
| 803 | + // size_t content_length = Blob::blob_size(body_obj); |
821 | 804 |
|
822 | 805 | JS::RootedString type_str(cx, Blob::type(body_obj));
|
823 | 806 | if (JS::GetStringLength(type_str) > 0) {
|
824 | 807 | host_type_str = core::encode(cx, type_str);
|
825 | 808 | MOZ_ASSERT(host_type_str);
|
826 |
| - content_type = host_type_str.ptr.get(); |
| 809 | + content_type = host_type_str.begin(); |
827 | 810 | }
|
828 | 811 | } else if (body_obj && JS::IsReadableStream(body_obj)) {
|
829 | 812 | if (RequestOrResponse::body_unusable(cx, body_obj)) {
|
|
0 commit comments