network.ts (hoppscotch-2.2.1) | : | network.ts (hoppscotch-3.0.0) | ||
---|---|---|---|---|
import { AxiosResponse, AxiosRequestConfig } from "axios" | import { AxiosResponse, AxiosRequestConfig } from "axios" | |||
import { BehaviorSubject, Observable } from "rxjs" | import { BehaviorSubject, Observable } from "rxjs" | |||
import cloneDeep from "lodash/cloneDeep" | import { cloneDeep } from "lodash-es" | |||
import * as T from "fp-ts/Task" | import * as T from "fp-ts/Task" | |||
import * as TE from "fp-ts/TaskEither" | import * as TE from "fp-ts/TaskEither" | |||
import { pipe } from "fp-ts/function" | import { pipe } from "fp-ts/function" | |||
import AxiosStrategy, { | import AxiosStrategy, { | |||
cancelRunningAxiosRequest, | cancelRunningAxiosRequest, | |||
} from "./strategies/AxiosStrategy" | } from "./strategies/AxiosStrategy" | |||
import ExtensionStrategy, { | import ExtensionStrategy, { | |||
cancelRunningExtensionRequest, | cancelRunningExtensionRequest, | |||
hasExtensionInstalled, | hasExtensionInstalled, | |||
} from "./strategies/ExtensionStrategy" | } from "./strategies/ExtensionStrategy" | |||
skipping to change at line 135 | skipping to change at line 135 | |||
// Assembling headers object | // Assembling headers object | |||
TE.bind("headers", ({ req }) => | TE.bind("headers", ({ req }) => | |||
TE.of( | TE.of( | |||
req.effectiveFinalHeaders.reduce((acc, { key, value }) => { | req.effectiveFinalHeaders.reduce((acc, { key, value }) => { | |||
return Object.assign(acc, { [key]: value }) | return Object.assign(acc, { [key]: value }) | |||
}, {}) | }, {}) | |||
) | ) | |||
), | ), | |||
// Assembling params object | // Assembling params object | |||
TE.bind("params", ({ req }) => | TE.bind("params", ({ req }) => { | |||
TE.of( | const params = new URLSearchParams() | |||
req.effectiveFinalParams.reduce((acc, { key, value }) => { | req.effectiveFinalParams.forEach((x) => { | |||
return Object.assign(acc, { [key]: value }) | params.append(x.key, x.value) | |||
}, {}) | }) | |||
) | return TE.of(params) | |||
), | }), | |||
// Keeping the backup start time | // Keeping the backup start time | |||
TE.bind("backupTimeStart", () => TE.of(Date.now())), | TE.bind("backupTimeStart", () => TE.of(Date.now())), | |||
// Running the request and getting the response | // Running the request and getting the response | |||
TE.bind("res", ({ req, headers, params }) => | TE.bind("res", ({ req, headers, params }) => | |||
runAppropriateStrategy({ | runAppropriateStrategy({ | |||
method: req.method as any, | method: req.method as any, | |||
url: req.effectiveFinalURL.trim(), | url: req.effectiveFinalURL.trim(), | |||
headers, | headers, | |||
End of changes. 2 change blocks. | ||||
8 lines changed or deleted | 8 lines changed or added |