-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade browserify and use readable-stream 4.x.x Workaround to whatwg/fetch#1438 Fix #785 Signed-off-by: reluc <relu.cri@gmail.com>
- Loading branch information
Showing
7 changed files
with
749 additions
and
647 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the W3C Software Notice and | ||
* Document License (2015-05-13) which is available at | ||
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 | ||
********************************************************************************/ | ||
import { ProtocolHelpers } from "@node-wot/core"; | ||
import { RequestInit, Request } from "node-fetch"; | ||
import { Readable } from "stream"; | ||
import { HttpForm, HTTPMethodName } from "./http"; | ||
import HttpClient from "./http-client-impl"; | ||
|
||
export default class BrowserHttpClient extends HttpClient { | ||
protected async generateFetchRequest( | ||
form: HttpForm, | ||
defaultMethod: HTTPMethodName, | ||
additionalOptions?: RequestInit | ||
): Promise<Request> { | ||
if (additionalOptions?.body instanceof Readable) { | ||
const buffer = await ProtocolHelpers.readStreamFully(additionalOptions.body); | ||
additionalOptions.body = buffer; | ||
} | ||
return super.generateFetchRequest(form, defaultMethod, additionalOptions); | ||
} | ||
} |
Oops, something went wrong.