Socket
Socket
Sign inDemoInstall

@aws-sdk/protocol-http

Package Overview
Dependencies
Maintainers
5
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/protocol-http - npm Package Compare versions

Comparing version 3.290.0 to 3.292.0

2

dist-cjs/Field.js

@@ -21,3 +21,3 @@ "use strict";

toString() {
return this.values.map((v) => (v.includes(",") ? `"${v}"` : v)).join(", ");
return this.values.map((v) => (v.includes(",") || v.includes(" ") ? `"${v}"` : v)).join(", ");
}

@@ -24,0 +24,0 @@ get() {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Fields = void 0;
const Field_1 = require("./Field");
class Fields {

@@ -23,12 +22,3 @@ constructor({ fields = [], encoding = "utf-8" }) {

}
getAll() {
return Object.values(this.entries);
}
static from(fieldsToCreate, encoding) {
return fieldsToCreate.reduce((fields, fieldArgs) => {
fields.setField(new Field_1.Field(fieldArgs));
return fields;
}, new Fields({ encoding }));
}
}
exports.Fields = Fields;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpRequest = void 0;
const Fields_1 = require("./Fields");
const headersProxy_1 = require("./headersProxy");
const queryProxy_1 = require("./queryProxy");
class HttpRequest {
constructor(options) {
this.protocol = "https";
this.hostname = "localhost";
this.path = "/";
this.query = {};
this.headers = {};
this.method = options.method || "GET";
this.destination = HttpRequest.getDefaultDestination(options);
this.fields = (0, headersProxy_1.headersToFields)(options.headers || {});
this.hostname = options.hostname || "localhost";
this.port = options.port;
this.query = options.query || {};
this.headers = options.headers || {};
this.body = options.body;
const httpRequest = this;
Object.defineProperties(httpRequest, {
protocol: {
enumerable: true,
get() {
return httpRequest.destination.protocol;
},
set(protocol) {
httpRequest.destination.protocol = protocol;
},
},
hostname: {
enumerable: true,
get() {
return httpRequest.destination.hostname;
},
set(hostname) {
httpRequest.destination.hostname = hostname;
},
},
port: {
enumerable: true,
get() {
const port = httpRequest.destination.port;
return port ? Number(port) : undefined;
},
set(port) {
httpRequest.destination.port = String(port);
},
},
path: {
enumerable: true,
get() {
return httpRequest.destination.pathname;
},
set(path) {
httpRequest.destination.pathname = path;
},
},
query: {
enumerable: true,
get() {
return (0, queryProxy_1.getQueryProxy)(httpRequest.destination.searchParams);
},
set(query) {
const searchParams = (0, queryProxy_1.queryToSearchParams)(query || {});
httpRequest.destination.search = searchParams.toString();
},
},
headers: {
enumerable: true,
get() {
return (0, headersProxy_1.getHeadersProxy)(httpRequest.fields);
},
set(headers) {
httpRequest.fields = (0, headersProxy_1.headersToFields)(headers);
},
},
});
this.protocol = options.protocol
? options.protocol.slice(-1) !== ":"
? `${options.protocol}:`
: options.protocol
: "https:";
this.path = options.path ? (options.path.charAt(0) !== "/" ? `/${options.path}` : options.path) : "/";
}
static from(options) {
const request = new HttpRequest(options);
if (options.destination) {
request.destination = options.destination;
}
if (options.fields) {
request.fields = options.fields;
}
return request;
}
static isInstance(request) {

@@ -100,26 +31,20 @@ if (!request)

clone() {
return HttpRequest.from({
const cloned = new HttpRequest({
...this,
destination: new URL(this.destination),
fields: Fields_1.Fields.from(this.fields.getAll().map((field) => ({
...field,
values: [...field.values],
}))),
headers: { ...this.headers },
});
if (cloned.query)
cloned.query = cloneQuery(cloned.query);
return cloned;
}
static getDefaultDestination(options) {
const protocol = options.protocol
? options.protocol.slice(-1) !== ":"
? `${options.protocol}:`
: options.protocol
: "https:";
const hostname = options.hostname || "localhost";
const port = options.port ? `:${String(options.port)}` : "";
const path = options.path ? (options.path.charAt(0) !== "/" ? `/${options.path}` : options.path) : "/";
const searchParams = (0, queryProxy_1.queryToSearchParams)(options.query || {});
const url = new URL(`${protocol}//${hostname}${port}${path}`);
url.search = searchParams.toString();
return url;
}
}
exports.HttpRequest = HttpRequest;
function cloneQuery(query) {
return Object.keys(query).reduce((carry, paramName) => {
const param = query[paramName];
return {
...carry,
[paramName]: Array.isArray(param) ? [...param] : param,
};
}, {});
}

@@ -18,3 +18,3 @@ import { FieldPosition } from "./FieldPosition";

toString() {
return this.values.map((v) => (v.includes(",") ? `"${v}"` : v)).join(", ");
return this.values.map((v) => (v.includes(",") || v.includes(" ") ? `"${v}"` : v)).join(", ");
}

@@ -21,0 +21,0 @@ get() {

@@ -1,2 +0,1 @@

import { Field } from "./Field";
export class Fields {

@@ -20,11 +19,2 @@ constructor({ fields = [], encoding = "utf-8" }) {

}
getAll() {
return Object.values(this.entries);
}
static from(fieldsToCreate, encoding) {
return fieldsToCreate.reduce((fields, fieldArgs) => {
fields.setField(new Field(fieldArgs));
return fields;
}, new Fields({ encoding }));
}
}

@@ -1,85 +0,16 @@

import { Fields } from "./Fields";
import { getHeadersProxy, headersToFields } from "./headersProxy";
import { getQueryProxy, queryToSearchParams } from "./queryProxy";
export class HttpRequest {
constructor(options) {
this.protocol = "https";
this.hostname = "localhost";
this.path = "/";
this.query = {};
this.headers = {};
this.method = options.method || "GET";
this.destination = HttpRequest.getDefaultDestination(options);
this.fields = headersToFields(options.headers || {});
this.hostname = options.hostname || "localhost";
this.port = options.port;
this.query = options.query || {};
this.headers = options.headers || {};
this.body = options.body;
const httpRequest = this;
Object.defineProperties(httpRequest, {
protocol: {
enumerable: true,
get() {
return httpRequest.destination.protocol;
},
set(protocol) {
httpRequest.destination.protocol = protocol;
},
},
hostname: {
enumerable: true,
get() {
return httpRequest.destination.hostname;
},
set(hostname) {
httpRequest.destination.hostname = hostname;
},
},
port: {
enumerable: true,
get() {
const port = httpRequest.destination.port;
return port ? Number(port) : undefined;
},
set(port) {
httpRequest.destination.port = String(port);
},
},
path: {
enumerable: true,
get() {
return httpRequest.destination.pathname;
},
set(path) {
httpRequest.destination.pathname = path;
},
},
query: {
enumerable: true,
get() {
return getQueryProxy(httpRequest.destination.searchParams);
},
set(query) {
const searchParams = queryToSearchParams(query || {});
httpRequest.destination.search = searchParams.toString();
},
},
headers: {
enumerable: true,
get() {
return getHeadersProxy(httpRequest.fields);
},
set(headers) {
httpRequest.fields = headersToFields(headers);
},
},
});
this.protocol = options.protocol
? options.protocol.slice(-1) !== ":"
? `${options.protocol}:`
: options.protocol
: "https:";
this.path = options.path ? (options.path.charAt(0) !== "/" ? `/${options.path}` : options.path) : "/";
}
static from(options) {
const request = new HttpRequest(options);
if (options.destination) {
request.destination = options.destination;
}
if (options.fields) {
request.fields = options.fields;
}
return request;
}
static isInstance(request) {

@@ -97,25 +28,19 @@ if (!request)

clone() {
return HttpRequest.from({
const cloned = new HttpRequest({
...this,
destination: new URL(this.destination),
fields: Fields.from(this.fields.getAll().map((field) => ({
...field,
values: [...field.values],
}))),
headers: { ...this.headers },
});
if (cloned.query)
cloned.query = cloneQuery(cloned.query);
return cloned;
}
static getDefaultDestination(options) {
const protocol = options.protocol
? options.protocol.slice(-1) !== ":"
? `${options.protocol}:`
: options.protocol
: "https:";
const hostname = options.hostname || "localhost";
const port = options.port ? `:${String(options.port)}` : "";
const path = options.path ? (options.path.charAt(0) !== "/" ? `/${options.path}` : options.path) : "/";
const searchParams = queryToSearchParams(options.query || {});
const url = new URL(`${protocol}//${hostname}${port}${path}`);
url.search = searchParams.toString();
return url;
}
}
function cloneQuery(query) {
return Object.keys(query).reduce((carry, paramName) => {
const param = query[paramName];
return {
...carry,
[paramName]: Array.isArray(param) ? [...param] : param,
};
}, {});
}

@@ -43,3 +43,3 @@ import { FieldPosition } from "./FieldPosition";

/**
* Get comma-delimited string to be sent over the wire.
* Get comma-delimited string.
*

@@ -46,0 +46,0 @@ * @returns String representation of {@link Field}.

@@ -1,2 +0,2 @@

import { Field, FieldOptions } from "./Field";
import { Field } from "./Field";
import { FieldPosition } from "./FieldPosition";

@@ -44,19 +44,2 @@ export declare type FieldsOptions = {

getByType(kind: FieldPosition): Field[];
/**
* Retrieves all the {@link Field}s in the collection.
* Includes headers and trailers.
*
* @returns All fields in the collection.
*/
getAll(): Field[];
/**
* Utility for creating {@link Fields} without having to
* construct each {@link Field} individually.
*
* @param fieldsToCreate List of arguments used to create each
* {@link Field}.
* @param encoding Optional encoding of resultant {@link Fields}.
* @returns The {@link Fields} instance.
*/
static from(fieldsToCreate: FieldOptions[], encoding?: string): Fields;
}

@@ -1,63 +0,20 @@

import { HeaderBag, QueryParameterBag, Request } from "@aws-sdk/types";
import { Fields } from "./Fields";
export interface HttpRequestOptions {
import { Endpoint, HeaderBag, HttpMessage, HttpRequest as IHttpRequest, QueryParameterBag } from "@aws-sdk/types";
declare type HttpRequestOptions = Partial<HttpMessage> & Partial<Endpoint> & {
method?: string;
protocol?: string;
hostname?: string;
port?: number;
path?: string;
query?: QueryParameterBag;
headers?: HeaderBag;
body?: any;
};
export interface HttpRequest extends IHttpRequest {
}
export interface HttpRequestFromOptions {
method?: string;
destination?: URL;
fields?: Fields;
body?: any;
}
export interface HttpRequest extends Request {
export declare class HttpRequest implements HttpMessage, Endpoint {
method: string;
destination: URL;
fields: Fields;
body?: any;
}
export declare class HttpRequest implements Request {
method: string;
destination: URL;
fields: Fields;
body?: any;
/**
* @deprecated Use protocol in {@link destination}
*/
protocol: string;
/**
* @deprecated Use hostname in {@link destination}
*/
hostname: string;
/**
* @deprecated Use port in {@link destination}
*/
port?: number;
/**
* @deprecated Use pathname in {@link destination}
*/
path: string;
/**
* @deprecated Use searchParams in {@link destination}
*/
query: QueryParameterBag;
/**
* @deprecated Use {@link fields}
*/
headers: HeaderBag;
/**
*
* @deprecated Use {@link HttpRequest.from}
*/
body?: any;
constructor(options: HttpRequestOptions);
static from(options: HttpRequestFromOptions): HttpRequest;
static isInstance(request: unknown): request is HttpRequest;
clone(): HttpRequest;
private static getDefaultDestination;
}
export {};

@@ -1,2 +0,2 @@

import { Field, FieldOptions } from "./Field";
import { Field } from "./Field";
import { FieldPosition } from "./FieldPosition";

@@ -15,4 +15,2 @@ export declare type FieldsOptions = {

getByType(kind: FieldPosition): Field[];
getAll(): Field[];
static from(fieldsToCreate: FieldOptions[], encoding?: string): Fields;
}

@@ -1,30 +0,15 @@

import { HeaderBag, QueryParameterBag, Request } from "@aws-sdk/types";
import { Fields } from "./Fields";
export interface HttpRequestOptions {
method?: string;
protocol?: string;
hostname?: string;
port?: number;
path?: string;
query?: QueryParameterBag;
headers?: HeaderBag;
body?: any;
}
export interface HttpRequestFromOptions {
method?: string;
destination?: URL;
fields?: Fields;
body?: any;
}
export interface HttpRequest extends Request {
import {
Endpoint,
HeaderBag,
HttpMessage,
HttpRequest as IHttpRequest,
QueryParameterBag,
} from "@aws-sdk/types";
declare type HttpRequestOptions = Partial<HttpMessage> &
Partial<Endpoint> & {
method?: string;
};
export interface HttpRequest extends IHttpRequest {}
export declare class HttpRequest implements HttpMessage, Endpoint {
method: string;
destination: URL;
fields: Fields;
body?: any;
}
export declare class HttpRequest implements Request {
method: string;
destination: URL;
fields: Fields;
body?: any;
protocol: string;

@@ -36,7 +21,7 @@ hostname: string;

headers: HeaderBag;
body?: any;
constructor(options: HttpRequestOptions);
static from(options: HttpRequestFromOptions): HttpRequest;
static isInstance(request: unknown): request is HttpRequest;
clone(): HttpRequest;
private static getDefaultDestination;
}
export {};
{
"name": "@aws-sdk/protocol-http",
"version": "3.290.0",
"version": "3.292.0",
"scripts": {

@@ -12,3 +12,3 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",

"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"test": "jest --coverage"
"test": "jest"
},

@@ -25,3 +25,3 @@ "main": "./dist-cjs/index.js",

"dependencies": {
"@aws-sdk/types": "3.290.0",
"@aws-sdk/types": "3.292.0",
"tslib": "^2.3.1"

@@ -53,5 +53,8 @@ },

"rimraf": "3.0.2",
"typedoc": "0.19.2",
"typedoc": "0.23.23",
"typescript": "~4.6.2"
},
"typedoc": {
"entryPoint": "src/index.ts"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc