mirror of
https://github.com/status-im/status-go.git
synced 2025-01-13 08:05:40 +00:00
6a096607cf
This PR adds Fetch API and fixes #289 by using concurrency safe Otto VM wrapper wherever it's possible. This involves new package geth/jail/vm that is used by jail and by our forked ottoext/{fetch/timers/loop} packages. It also adds more tests that are supposed to be run with --race flag of go test.
35 lines
706 B
JavaScript
35 lines
706 B
JavaScript
const Headers = require('./headers');
|
|
|
|
export default class Request {
|
|
constructor(input, {method, headers, redirect, body}={}) {
|
|
this.method = 'GET';
|
|
this.headers = new Headers({});
|
|
this.redirect = 'manual';
|
|
this.body = null;
|
|
|
|
if (input instanceof Request) {
|
|
this.url = input.url;
|
|
this.method = input.method;
|
|
this.headers = new Headers(input.headers);
|
|
this.redirect = input.redirect;
|
|
} else {
|
|
this.url = input;
|
|
}
|
|
|
|
if (method) {
|
|
this.method = method;
|
|
}
|
|
|
|
if (headers) {
|
|
this.headers = new Headers(headers);
|
|
}
|
|
|
|
if (redirect) {
|
|
this.redirect = redirect;
|
|
}
|
|
|
|
if (body) {
|
|
this.body = body;
|
|
}
|
|
}
|
|
} |