Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
483 changes: 252 additions & 231 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion packages/binding-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
],
"main": "dist/http.js",
"types": "dist/http.d.ts",
"browser": "dist/http-browser.js",
"browser": {
"./dist/http.js": "./dist/http-browser.js",
"./dist/http-client.js": "./dist/http-client-browser.js"
},
"devDependencies": {
"@testdeck/mocha": "^0.1.2",
"@types/accept-language-parser": "^1.5.2",
Expand Down
33 changes: 33 additions & 0 deletions packages/binding-http/src/http-client-browser.ts
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);
}
}
Loading