Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@corefunc/http

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@corefunc/http - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

LICENSE.md

2

dist/http.js

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

!function(E,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((E=E||self).CoreFuncHttp={})}(this,(function(E){"use strict";const e={ACCEPT:"Accept",ACCEPT_CHARSET:"Accept-Charset",ACCEPT_ENCODING:"Accept-Encoding",ACCEPT_LANGUAGE:"Accept-Language",ACCEPT_RANGES:"Accept-Ranges",ACCESS_CONTROL_ALLOW_CREDENTIALS:"Access-Control-Allow-Credentials",ACCESS_CONTROL_ALLOW_HEADERS:"Access-Control-Allow-Headers",ACCESS_CONTROL_ALLOW_METHODS:"Access-Control-Allow-Methods",ACCESS_CONTROL_ALLOW_ORIGIN:"Access-Control-Allow-Origin",ACCESS_CONTROL_EXPOSE_HEADERS:"Access-Control-Expose-Headers",ACCESS_CONTROL_MAX_AGE:"Access-Control-Max-Age",ACCESS_CONTROL_REQUEST_HEADERS:"Access-Control-Request-Headers",ACCESS_CONTROL_REQUEST_METHOD:"Access-Control-Request-Method",AGE:"Age",ALLOW:"Allow",AUTHORIZATION:"Authorization",CACHE_CONTROL:"Cache-Control",CONNECTION:"Connection",CONTENT_DISPOSITION:"Content-Disposition",CONTENT_ENCODING:"Content-Encoding",CONTENT_LANGUAGE:"Content-Language",CONTENT_LENGTH:"Content-Length",CONTENT_LOCATION:"Content-Location",CONTENT_MD5:"Content-MD5",CONTENT_RANGE:"Content-Range",CONTENT_SECURITY_POLICY:"Content-Security-Policy",CONTENT_SECURITY_POLICY_REPORT_ONLY:"Content-Security-Policy-Report-Only",CONTENT_TYPE:"Content-Type",COOKIE:"Cookie",DATE:"Date",DNT:"DNT",ETAG:"ETag",EXPECT:"Expect",EXPIRES:"Expires",FOLLOW_ONLY_WHEN_PRERENDER_SHOWN:"Follow-Only-When-Prerender-Shown",FORWARDED:"Forwarded",FROM:"From",HOST:"Host",IF_MATCH:"If-Match",IF_MODIFIED_SINCE:"If-Modified-Since",IF_NONE_MATCH:"If-None-Match",IF_RANGE:"If-Range",IF_UNMODIFIED_SINCE:"If-Unmodified-Since",LAST_EVENT_ID:"Last-Event-ID",LAST_MODIFIED:"Last-Modified",LINK:"Link",LOCATION:"Location",MAX_FORWARDS:"Max-Forwards",ORIGIN:"Origin",P3P:"P3P",PING_FROM:"Ping-From",PING_TO:"Ping-To",PRAGMA:"Pragma",PROXY_AUTHENTICATE:"Proxy-Authenticate",PROXY_AUTHORIZATION:"Proxy-Authorization",PUBLIC_KEY_PINS:"Public-Key-Pins",PUBLIC_KEY_PINS_REPORT_ONLY:"Public-Key-Pins-Report-Only",RANGE:"Range",REFERER:"Referer",REFRESH:"Refresh",RETRY_AFTER:"Retry-After",SERVER:"Server",SERVICE_WORKER:"Service-Worker",SERVICE_WORKER_ALLOWED:"Service-Worker-Allowed",SET_COOKIE2:"Set-Cookie2",SET_COOKIE:"Set-Cookie",STRICT_TRANSPORT_SECURITY:"Strict-Transport-Security",TE:"TE",TIMING_ALLOW_ORIGIN:"Timing-Allow-Origin",TRAILER:"Trailer",TRANSFER_ENCODING:"Transfer-Encoding",UPGRADE:"Upgrade",USER_AGENT:"User-Agent",VARY:"Vary",VIA:"Via",WARNING:"Warning",WWW_AUTHENTICATE:"WWW-Authenticate",X_CONTENT_SECURITY_POLICY:"X-Content-Security-Policy",X_CONTENT_SECURITY_POLICY_REPORT_ONLY:"X-Content-Security-Policy-Report-Only",X_CONTENT_TYPE_OPTIONS:"X-Content-Type-Options",X_DO_NOT_TRACK:"X-Do-Not-Track",X_FORWARDED_FOR:"X-Forwarded-For",X_FORWARDED_HOST:"X-Forwarded-Host",X_FORWARDED_PORT:"X-Forwarded-Port",X_FORWARDED_PROTO:"X-Forwarded-Proto",X_FRAME_OPTIONS:"X-Frame-Options",X_POWERED_BY:"X-Powered-By",X_REQUESTED_WITH:"X-Requested-With",X_USER_IP:"X-User-IP",X_WEBKIT_CSP:"X-WebKit-CSP",X_WEBKIT_CSP_REPORT_ONLY:"X-WebKit-CSP-Report-Only",X_XSS_PROTECTION:"X-XSS-Protection"};function constant(E,e){return`${E}/${e}`}function text(E){return constant("text",E)}function image(E){return constant("image",E)}function audio(E){return constant("audio",E)}function video(E){return constant("video",E)}function application(E){return constant("application",E)}Object.freeze(e),Object.seal(e);const t={ANY:constant("*","*"),APP:application("*"),APP_ATOM:application("atom+xml"),APP_BINARY:application("binary"),APP_BZIP2:application("x-bzip2"),APP_DART:application("dart"),APP_EOT:application("vnd.ms-fontobject"),APP_EPUB:application("epub+zip"),APP_FORM_DATA:application("x-www-form-urlencoded"),APP_GZIP:application("x-gzip"),APP_JAVASCRIPT:application("javascript"),APP_JSON:application("json"),APP_KEY_ARCHIVE:application("pkcs12"),APP_KML:application("vnd.google-earth.kml+xml"),APP_KMZ:application("vnd.google-earth.kmz"),APP_LD_JSON:application("ld+json"),APP_MANIFEST_JSON:application("manifest+json"),APP_MBOX:application("mbox"),APP_MICROSOFT_EXCEL:application("vnd.ms-excel"),APP_MICROSOFT_POWERPOINT:application("vnd.ms-powerpoint"),APP_MICROSOFT_WORD:application("msword"),APP_MOBILE_CONFIG:application("x-apple-aspen-config"),APP_NACL:application("x-nacl"),APP_NACL_PORTABLE:application("x-pnacl"),APP_OCTET_STREAM:application("octet-stream"),APP_OGG:application("ogg"),APP_PASSBOOK:application("vnd.apple.pkpass"),APP_PDF:application("pdf"),APP_POSTSCRIPT:application("postscript"),APP_PROTOBUF:application("protobuf"),APP_RDF_XML:application("rdf+xml"),APP_RTF:application("rtf"),APP_SFNT:application("font-sfnt"),APP_SHOCKWAVE_FLASH:application("x-shockwave-flash"),APP_SKETCHUP:application("vnd.sketchup.skp"),APP_SOAP_XML:application("soap+xml"),APP_TAR:application("x-tar"),APP_WOFF2:application("font-woff2"),APP_WOFF:application("font-woff"),APP_XHTML:application("xhtml+xml"),APP_XML:application("xml"),APP_XRD:application("xrd+xml"),APP_ZIP:application("zip"),AUDIO:audio("*"),AUDIO_AAC:audio("aac"),AUDIO_BASIC:audio("basic"),AUDIO_L24:audio("l24"),AUDIO_MP4:audio("mp4"),AUDIO_MPEG:audio("mpeg"),AUDIO_OGG:audio("ogg"),AUDIO_VND_REAL:audio("vnd.rn-realaudio"),AUDIO_VND_WAVE:audio("vnd.wave"),AUDIO_VORBIS:audio("vorbis"),AUDIO_WAX:audio("x-ms-wax"),AUDIO_WEBM:audio("webm"),AUDIO_WMA:audio("x-ms-wma"),IMAGE:image("*"),IMAGE_APNG:image("apng"),IMAGE_AVIF:image("avif"),IMAGE_AVIF_SEQ:image("avif-sequence"),IMAGE_BMP:image("bmp"),IMAGE_CRW:image("x-canon-crw"),IMAGE_GIF:image("gif"),IMAGE_HEIC:image("heic"),IMAGE_HEIF:image("heif"),IMAGE_ICO:image("vnd.microsoft.icon"),IMAGE_JPEG:image("jpeg"),IMAGE_PNG:image("png"),IMAGE_PSD:image("vnd.adobe.photoshop"),IMAGE_SVG:image("svg+xml"),IMAGE_TIFF:image("tiff"),IMAGE_WEBP:image("webp"),TEXT:text("*"),TEXT_CACHE_MANIFEST:text("cache-manifest"),TEXT_CALENDAR:text("calendar"),TEXT_CSS:text("css"),TEXT_CSV:text("csv"),TEXT_HTML:text("html"),TEXT_JAVASCRIPT:text("javascript"),TEXT_PLAIN:text("plain"),TEXT_TSV:text("tab-separated-values"),TEXT_VCARD:text("vcard"),TEXT_VTT:text("vtt"),TEXT_WML:text("vnd.wap.wml"),TEXT_XML:text("xml"),VIDEO:video("*"),VIDEO_AV1:video("av1"),VIDEO_FLV:video("x-flv"),VIDEO_MP4:video("mp4"),VIDEO_MPEG:video("mpeg"),VIDEO_OGG:video("ogg"),VIDEO_QUICKTIME:video("quicktime"),VIDEO_THREE_GPP2:video("3gpp2"),VIDEO_THREE_GPP:video("3gpp"),VIDEO_WEBM:video("webm"),VIDEO_WMV:video("x-ms-wmv")};Object.freeze(t),Object.seal(t);const T={CONNECT:"CONNECT",DELETE:"DELETE",GET:"GET",HEAD:"HEAD",OPTIONS:"OPTIONS",PATCH:"PATCH",POST:"POST",PUT:"PUT",TRACE:"TRACE"};Object.freeze(T),Object.seal(T);const _={CONTINUE:100,SWITCHING_PROTOCOLS:101,PROCESSING:102,EARLY_HINTS:103,OK:200,CREATED:201,ACCEPTED:202,NON_AUTHORITATIVE_INFORMATION:203,NO_CONTENT:204,RESET_CONTENT:205,PARTIAL_CONTENT:206,MULTI_STATUS:207,ALREADY_REPORTED:208,IM_USED:226,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,MOVED_TEMPORARILY:302,SEE_OTHER:303,NOT_MODIFIED:304,USE_PROXY:305,UNUSED:306,TEMPORARY_REDIRECT:307,PERMANENT_REDIRECT:308,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,REQUEST_URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,REQUESTED_RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,IM_A_TEAPOT:418,INSUFFICIENT_SPACE_ON_RESOURCE:419,ENHANCE_YOUR_CALM:420,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,WOULD_BLOCK:430,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,BANDWIDTH_LIMIT_EXCEEDED:509,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};Object.freeze(_),Object.seal(_);const o={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Unused",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",419:"Insufficient space on resource",420:"Enhance your calm",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",430:"Would Block",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};Object.freeze(o),Object.seal(o);const O=[204,205,304];Object.freeze(O),Object.seal(O);const A=[300,301,302,303,305,307,308];Object.freeze(A),Object.seal(A);const n=[502,503,504];function httpStatusCode(E){return Number.parseInt(Array.isArray(E)?""+E[0]:""+E,10)}function httpStatusText(E){return Array.isArray(E)?o[""+E[0]]:o[""+E]}function httpResponse(E,e){const t=httpStatusCode(E);let T=httpStatusText(t);"string"==typeof e?T=e:Array.isArray(E)&&"string"==typeof E[0]&&E[0].length>4&&(T=E[0].substr(4));const _=e&&"object"==typeof e&&!Array.isArray(e)?e:{};return t>399&&("error"in _||(_.error=!0)),{message:T,statusCode:t,..._}}Object.freeze(n),Object.seal(n);class Header{constructor(E={}){this.headers={...E}}ContentType(E=t.APP_JSON){return this.headers[e.CONTENT_TYPE]=E,this}toObject(){return{...this}}valueOf(){return this.toJSON()}toJSON(){return JSON.stringify(this.toObject())}}E.ACCEPTED=202,E.ALREADY_REPORTED=208,E.BAD_GATEWAY=502,E.BAD_REQUEST=400,E.BANDWIDTH_LIMIT_EXCEEDED=509,E.CONFLICT=409,E.CONTINUE=100,E.CREATED=201,E.EARLY_HINTS=103,E.ENHANCE_YOUR_CALM=420,E.EXPECTATION_FAILED=417,E.FAILED_DEPENDENCY=424,E.FORBIDDEN=403,E.GATEWAY_TIMEOUT=504,E.GONE=410,E.HTTP_HEADER=e,E.HTTP_MEDIA_TYPE=t,E.HTTP_METHOD=T,E.HTTP_VERSION_NOT_SUPPORTED=505,E.Headers=function Headers(E={}){return new Header(E)},E.IM_A_TEAPOT=418,E.IM_USED=226,E.INSUFFICIENT_SPACE_ON_RESOURCE=419,E.INSUFFICIENT_STORAGE=507,E.INTERNAL_SERVER_ERROR=500,E.LENGTH_REQUIRED=411,E.LOCKED=423,E.LOOP_DETECTED=508,E.METHOD_NOT_ALLOWED=405,E.MISDIRECTED_REQUEST=421,E.MOVED_PERMANENTLY=301,E.MOVED_TEMPORARILY=302,E.MULTIPLE_CHOICES=300,E.MULTI_STATUS=207,E.NETWORK_AUTHENTICATION_REQUIRED=511,E.NON_AUTHORITATIVE_INFORMATION=203,E.NOT_ACCEPTABLE=406,E.NOT_EXTENDED=510,E.NOT_FOUND=404,E.NOT_IMPLEMENTED=501,E.NOT_MODIFIED=304,E.NO_CONTENT=204,E.OK=200,E.PARTIAL_CONTENT=206,E.PAYLOAD_TOO_LARGE=413,E.PAYMENT_REQUIRED=402,E.PERMANENT_REDIRECT=308,E.PRECONDITION_FAILED=412,E.PRECONDITION_REQUIRED=428,E.PROCESSING=102,E.PROXY_AUTHENTICATION_REQUIRED=407,E.REQUESTED_RANGE_NOT_SATISFIABLE=416,E.REQUEST_HEADER_FIELDS_TOO_LARGE=431,E.REQUEST_TIMEOUT=408,E.REQUEST_URI_TOO_LONG=414,E.RESET_CONTENT=205,E.SEE_OTHER=303,E.SERVICE_UNAVAILABLE=503,E.STATUS_CODE_EMPTY=O,E.STATUS_CODE_REDIRECT=A,E.STATUS_CODE_RETRY=n,E.STATUS_CODE_TAG=_,E.STATUS_CODE_TEXT=o,E.SWITCHING_PROTOCOLS=101,E.TEMPORARY_REDIRECT=307,E.TOO_EARLY=425,E.TOO_MANY_REQUESTS=429,E.UNAUTHORIZED=401,E.UNAVAILABLE_FOR_LEGAL_REASONS=451,E.UNPROCESSABLE_ENTITY=422,E.UNSUPPORTED_MEDIA_TYPE=415,E.UNUSED=306,E.UPGRADE_REQUIRED=426,E.USE_PROXY=305,E.VARIANT_ALSO_NEGOTIATES=506,E.WOULD_BLOCK=430,E.httpResponse=httpResponse,E.httpResponseHtml=function httpResponseHtml(E,e){const t=httpStatusCode(E);let T=`<!DOCTYPE html><html><body><h1>${t} ${httpStatusText(t)}</h1>`;return"string"==typeof e?T=`${T}<h2>${e}</h2>`:Array.isArray(E)&&"string"==typeof E[0]&&E[0].length>4?T=`${T}<h2>${E[0].substr(4)}</h2>`:e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(E=>{T=`${T}<p><strong>${E}</strong><span>${e[E]}</span></p>`}),T+"</body></html>"},E.httpResponseJson=function httpResponseJson(E,e){return JSON.stringify(httpResponse(E,e))},E.httpResponseText=function httpResponseText(E,e){const t=httpStatusCode(E);let T=`${t} ${httpStatusText(t)}`;return"string"==typeof e?T=`${T}\n${e}`:Array.isArray(E)&&"string"==typeof E[0]&&E[0].length>4?T=`${T}\n${E[0].substr(4)}`:e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(E=>{T=`${T}\n${E}\t${e[E]}`}),T},E.httpResponseXml=function httpResponseXml(E,e){let t='<?xml version="1.0" encoding="UTF-8"?><root>';const T=httpResponse(E,e);return Object.keys(T).forEach(E=>{t=`${t}<${E}>${T[E]}</${E}>`}),t+"</root>"},E.httpStatusCode=httpStatusCode,E.httpStatusText=httpStatusText,Object.defineProperty(E,"__esModule",{value:!0})}));
!function(E,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((E=E||self).CoreFuncHttp={})}(this,(function(E){"use strict";const e={ACCEPT:"Accept",ACCEPT_CHARSET:"Accept-Charset",ACCEPT_ENCODING:"Accept-Encoding",ACCEPT_LANGUAGE:"Accept-Language",ACCEPT_RANGES:"Accept-Ranges",ACCESS_CONTROL_ALLOW_CREDENTIALS:"Access-Control-Allow-Credentials",ACCESS_CONTROL_ALLOW_HEADERS:"Access-Control-Allow-Headers",ACCESS_CONTROL_ALLOW_METHODS:"Access-Control-Allow-Methods",ACCESS_CONTROL_ALLOW_ORIGIN:"Access-Control-Allow-Origin",ACCESS_CONTROL_EXPOSE_HEADERS:"Access-Control-Expose-Headers",ACCESS_CONTROL_MAX_AGE:"Access-Control-Max-Age",ACCESS_CONTROL_REQUEST_HEADERS:"Access-Control-Request-Headers",ACCESS_CONTROL_REQUEST_METHOD:"Access-Control-Request-Method",AGE:"Age",ALLOW:"Allow",AUTHORIZATION:"Authorization",CACHE_CONTROL:"Cache-Control",CONNECTION:"Connection",CONTENT_DISPOSITION:"Content-Disposition",CONTENT_ENCODING:"Content-Encoding",CONTENT_LANGUAGE:"Content-Language",CONTENT_LENGTH:"Content-Length",CONTENT_LOCATION:"Content-Location",CONTENT_MD5:"Content-MD5",CONTENT_RANGE:"Content-Range",CONTENT_SECURITY_POLICY:"Content-Security-Policy",CONTENT_SECURITY_POLICY_REPORT_ONLY:"Content-Security-Policy-Report-Only",CONTENT_TYPE:"Content-Type",COOKIE:"Cookie",DATE:"Date",DNT:"DNT",ETAG:"ETag",EXPECT:"Expect",EXPIRES:"Expires",FOLLOW_ONLY_WHEN_PRERENDER_SHOWN:"Follow-Only-When-Prerender-Shown",FORWARDED:"Forwarded",FROM:"From",HOST:"Host",IF_MATCH:"If-Match",IF_MODIFIED_SINCE:"If-Modified-Since",IF_NONE_MATCH:"If-None-Match",IF_RANGE:"If-Range",IF_UNMODIFIED_SINCE:"If-Unmodified-Since",LAST_EVENT_ID:"Last-Event-ID",LAST_MODIFIED:"Last-Modified",LINK:"Link",LOCATION:"Location",MAX_FORWARDS:"Max-Forwards",ORIGIN:"Origin",P3P:"P3P",PING_FROM:"Ping-From",PING_TO:"Ping-To",PRAGMA:"Pragma",PROXY_AUTHENTICATE:"Proxy-Authenticate",PROXY_AUTHORIZATION:"Proxy-Authorization",PUBLIC_KEY_PINS:"Public-Key-Pins",PUBLIC_KEY_PINS_REPORT_ONLY:"Public-Key-Pins-Report-Only",RANGE:"Range",REFERER:"Referer",REFRESH:"Refresh",RETRY_AFTER:"Retry-After",SERVER:"Server",SERVICE_WORKER:"Service-Worker",SERVICE_WORKER_ALLOWED:"Service-Worker-Allowed",SET_COOKIE2:"Set-Cookie2",SET_COOKIE:"Set-Cookie",STRICT_TRANSPORT_SECURITY:"Strict-Transport-Security",TE:"TE",TIMING_ALLOW_ORIGIN:"Timing-Allow-Origin",TRAILER:"Trailer",TRANSFER_ENCODING:"Transfer-Encoding",UPGRADE:"Upgrade",USER_AGENT:"User-Agent",VARY:"Vary",VIA:"Via",WARNING:"Warning",WWW_AUTHENTICATE:"WWW-Authenticate",X_CONTENT_SECURITY_POLICY:"X-Content-Security-Policy",X_CONTENT_SECURITY_POLICY_REPORT_ONLY:"X-Content-Security-Policy-Report-Only",X_CONTENT_TYPE_OPTIONS:"X-Content-Type-Options",X_DO_NOT_TRACK:"X-Do-Not-Track",X_FORWARDED_FOR:"X-Forwarded-For",X_FORWARDED_HOST:"X-Forwarded-Host",X_FORWARDED_PORT:"X-Forwarded-Port",X_FORWARDED_PROTO:"X-Forwarded-Proto",X_FRAME_OPTIONS:"X-Frame-Options",X_POWERED_BY:"X-Powered-By",X_REQUESTED_WITH:"X-Requested-With",X_USER_IP:"X-User-IP",X_WEBKIT_CSP:"X-WebKit-CSP",X_WEBKIT_CSP_REPORT_ONLY:"X-WebKit-CSP-Report-Only",X_XSS_PROTECTION:"X-XSS-Protection"};function constant(E,e){return`${E}/${e}`}function text(E){return constant("text",E)}function image(E){return constant("image",E)}function audio(E){return constant("audio",E)}function video(E){return constant("video",E)}function application(E){return constant("application",E)}Object.freeze(e),Object.seal(e);const t={ANY:constant("*","*"),APP:application("*"),APP_ATOM:application("atom+xml"),APP_BINARY:application("binary"),APP_BZIP2:application("x-bzip2"),APP_DART:application("dart"),APP_EOT:application("vnd.ms-fontobject"),APP_EPUB:application("epub+zip"),APP_FORM_DATA:application("x-www-form-urlencoded"),APP_GZIP:application("x-gzip"),APP_JAVASCRIPT:application("javascript"),APP_JSON:application("json"),APP_KEY_ARCHIVE:application("pkcs12"),APP_KML:application("vnd.google-earth.kml+xml"),APP_KMZ:application("vnd.google-earth.kmz"),APP_LD_JSON:application("ld+json"),APP_MANIFEST_JSON:application("manifest+json"),APP_MBOX:application("mbox"),APP_MICROSOFT_EXCEL:application("vnd.ms-excel"),APP_MICROSOFT_POWERPOINT:application("vnd.ms-powerpoint"),APP_MICROSOFT_WORD:application("msword"),APP_MOBILE_CONFIG:application("x-apple-aspen-config"),APP_NACL:application("x-nacl"),APP_NACL_PORTABLE:application("x-pnacl"),APP_OCTET_STREAM:application("octet-stream"),APP_OGG:application("ogg"),APP_PASSBOOK:application("vnd.apple.pkpass"),APP_PDF:application("pdf"),APP_POSTSCRIPT:application("postscript"),APP_PROTOBUF:application("protobuf"),APP_RDF_XML:application("rdf+xml"),APP_RTF:application("rtf"),APP_SFNT:application("font-sfnt"),APP_SHOCKWAVE_FLASH:application("x-shockwave-flash"),APP_SKETCHUP:application("vnd.sketchup.skp"),APP_SOAP_XML:application("soap+xml"),APP_TAR:application("x-tar"),APP_WOFF2:application("font-woff2"),APP_WOFF:application("font-woff"),APP_XHTML:application("xhtml+xml"),APP_XML:application("xml"),APP_XRD:application("xrd+xml"),APP_ZIP:application("zip"),AUDIO:audio("*"),AUDIO_AAC:audio("aac"),AUDIO_BASIC:audio("basic"),AUDIO_L24:audio("l24"),AUDIO_MP4:audio("mp4"),AUDIO_MPEG:audio("mpeg"),AUDIO_OGG:audio("ogg"),AUDIO_VND_REAL:audio("vnd.rn-realaudio"),AUDIO_VND_WAVE:audio("vnd.wave"),AUDIO_VORBIS:audio("vorbis"),AUDIO_WAX:audio("x-ms-wax"),AUDIO_WEBM:audio("webm"),AUDIO_WMA:audio("x-ms-wma"),IMAGE:image("*"),IMAGE_APNG:image("apng"),IMAGE_AVIF:image("avif"),IMAGE_AVIF_SEQ:image("avif-sequence"),IMAGE_BMP:image("bmp"),IMAGE_CRW:image("x-canon-crw"),IMAGE_GIF:image("gif"),IMAGE_HEIC:image("heic"),IMAGE_HEIF:image("heif"),IMAGE_ICO:image("vnd.microsoft.icon"),IMAGE_JPEG:image("jpeg"),IMAGE_PNG:image("png"),IMAGE_PSD:image("vnd.adobe.photoshop"),IMAGE_SVG:image("svg+xml"),IMAGE_TIFF:image("tiff"),IMAGE_WEBP:image("webp"),TEXT:text("*"),TEXT_CACHE_MANIFEST:text("cache-manifest"),TEXT_CALENDAR:text("calendar"),TEXT_CSS:text("css"),TEXT_CSV:text("csv"),TEXT_HTML:text("html"),TEXT_JAVASCRIPT:text("javascript"),TEXT_PLAIN:text("plain"),TEXT_TSV:text("tab-separated-values"),TEXT_VCARD:text("vcard"),TEXT_VTT:text("vtt"),TEXT_WML:text("vnd.wap.wml"),TEXT_XML:text("xml"),VIDEO:video("*"),VIDEO_AV1:video("av1"),VIDEO_FLV:video("x-flv"),VIDEO_MP4:video("mp4"),VIDEO_MPEG:video("mpeg"),VIDEO_OGG:video("ogg"),VIDEO_QUICKTIME:video("quicktime"),VIDEO_THREE_GPP2:video("3gpp2"),VIDEO_THREE_GPP:video("3gpp"),VIDEO_WEBM:video("webm"),VIDEO_WMV:video("x-ms-wmv")};Object.freeze(t),Object.seal(t);const T={CONNECT:"CONNECT",DELETE:"DELETE",GET:"GET",HEAD:"HEAD",OPTIONS:"OPTIONS",PATCH:"PATCH",POST:"POST",PUT:"PUT",TRACE:"TRACE"};Object.freeze(T),Object.seal(T);const _={CONTINUE:100,SWITCHING_PROTOCOLS:101,PROCESSING:102,EARLY_HINTS:103,OK:200,CREATED:201,ACCEPTED:202,NON_AUTHORITATIVE_INFORMATION:203,NO_CONTENT:204,RESET_CONTENT:205,PARTIAL_CONTENT:206,MULTI_STATUS:207,ALREADY_REPORTED:208,IM_USED:226,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,MOVED_TEMPORARILY:302,SEE_OTHER:303,NOT_MODIFIED:304,USE_PROXY:305,UNUSED:306,TEMPORARY_REDIRECT:307,PERMANENT_REDIRECT:308,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,REQUEST_URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,REQUESTED_RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,IM_A_TEAPOT:418,INSUFFICIENT_SPACE_ON_RESOURCE:419,ENHANCE_YOUR_CALM:420,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,WOULD_BLOCK:430,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,BANDWIDTH_LIMIT_EXCEEDED:509,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};Object.freeze(_),Object.seal(_);const o={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Unused",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",419:"Insufficient space on resource",420:"Enhance your calm",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",430:"Would Block",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};Object.freeze(o),Object.seal(o);const O=[204,205,304];Object.freeze(O),Object.seal(O);const A=[300,301,302,303,305,307,308];Object.freeze(A),Object.seal(A);const n=[502,503,504];function httpStatusCode(E){return Number.parseInt(Array.isArray(E)?""+E[0]:""+E,10)}function httpStatusText(E){return Array.isArray(E)?o[""+E[0]]:o[""+E]}function httpResponse(E,e){const t=httpStatusCode(E);let T=httpStatusText(t);"string"==typeof e?T=e:Array.isArray(E)&&"string"==typeof E[0]&&E[0].length>4&&(T=E[0].substr(4));const _=e&&"object"==typeof e&&!Array.isArray(e)?e:{};return t>399&&("error"in _||(_.error=!0)),{message:T,statusCode:t,..._}}Object.freeze(n),Object.seal(n);class Header{constructor(E={}){this.headers={...E}}toObject(){return{...this}}valueOf(){return this.toJSON()}toJSON(){return JSON.stringify(this.toObject())}ContentLength(E){return this.headers[e.CONTENT_LENGTH]=""+E,this}ContentType(E=t.APP_JSON,T="",_=""){return this.headers[e.CONTENT_TYPE]=E,T.length&&(this.headers[e.CONTENT_TYPE]+="; charset="+T,_.length&&(this.headers[e.CONTENT_TYPE]+="; boundary="+_)),this}}E.ACCEPTED=202,E.ALREADY_REPORTED=208,E.BAD_GATEWAY=502,E.BAD_REQUEST=400,E.BANDWIDTH_LIMIT_EXCEEDED=509,E.CONFLICT=409,E.CONTINUE=100,E.CREATED=201,E.EARLY_HINTS=103,E.ENHANCE_YOUR_CALM=420,E.EXPECTATION_FAILED=417,E.FAILED_DEPENDENCY=424,E.FORBIDDEN=403,E.GATEWAY_TIMEOUT=504,E.GONE=410,E.HTTP_HEADER=e,E.HTTP_MEDIA_TYPE=t,E.HTTP_METHOD=T,E.HTTP_VERSION_NOT_SUPPORTED=505,E.Header=Header,E.Headers=function Headers(E={}){return new Header(E)},E.IM_A_TEAPOT=418,E.IM_USED=226,E.INSUFFICIENT_SPACE_ON_RESOURCE=419,E.INSUFFICIENT_STORAGE=507,E.INTERNAL_SERVER_ERROR=500,E.LENGTH_REQUIRED=411,E.LOCKED=423,E.LOOP_DETECTED=508,E.METHOD_NOT_ALLOWED=405,E.MISDIRECTED_REQUEST=421,E.MOVED_PERMANENTLY=301,E.MOVED_TEMPORARILY=302,E.MULTIPLE_CHOICES=300,E.MULTI_STATUS=207,E.NETWORK_AUTHENTICATION_REQUIRED=511,E.NON_AUTHORITATIVE_INFORMATION=203,E.NOT_ACCEPTABLE=406,E.NOT_EXTENDED=510,E.NOT_FOUND=404,E.NOT_IMPLEMENTED=501,E.NOT_MODIFIED=304,E.NO_CONTENT=204,E.OK=200,E.PARTIAL_CONTENT=206,E.PAYLOAD_TOO_LARGE=413,E.PAYMENT_REQUIRED=402,E.PERMANENT_REDIRECT=308,E.PRECONDITION_FAILED=412,E.PRECONDITION_REQUIRED=428,E.PROCESSING=102,E.PROXY_AUTHENTICATION_REQUIRED=407,E.REQUESTED_RANGE_NOT_SATISFIABLE=416,E.REQUEST_HEADER_FIELDS_TOO_LARGE=431,E.REQUEST_TIMEOUT=408,E.REQUEST_URI_TOO_LONG=414,E.RESET_CONTENT=205,E.SEE_OTHER=303,E.SERVICE_UNAVAILABLE=503,E.STATUS_CODE_EMPTY=O,E.STATUS_CODE_REDIRECT=A,E.STATUS_CODE_RETRY=n,E.STATUS_CODE_TAG=_,E.STATUS_CODE_TEXT=o,E.SWITCHING_PROTOCOLS=101,E.TEMPORARY_REDIRECT=307,E.TOO_EARLY=425,E.TOO_MANY_REQUESTS=429,E.UNAUTHORIZED=401,E.UNAVAILABLE_FOR_LEGAL_REASONS=451,E.UNPROCESSABLE_ENTITY=422,E.UNSUPPORTED_MEDIA_TYPE=415,E.UNUSED=306,E.UPGRADE_REQUIRED=426,E.USE_PROXY=305,E.VARIANT_ALSO_NEGOTIATES=506,E.WOULD_BLOCK=430,E.httpResponse=httpResponse,E.httpResponseHtml=function httpResponseHtml(E,e){const t=httpStatusCode(E);let T=`<!DOCTYPE html><html><body><h1>${t} ${httpStatusText(t)}</h1>`;return"string"==typeof e?T=`${T}<h2>${e}</h2>`:Array.isArray(E)&&"string"==typeof E[0]&&E[0].length>4?T=`${T}<h2>${E[0].substr(4)}</h2>`:e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(E=>{T=`${T}<p><strong>${E}</strong><span>${e[E]}</span></p>`}),T+"</body></html>"},E.httpResponseJson=function httpResponseJson(E,e){return JSON.stringify(httpResponse(E,e))},E.httpResponseText=function httpResponseText(E,e){const t=httpStatusCode(E);let T=`${t} ${httpStatusText(t)}`;return"string"==typeof e?T=`${T}\n${e}`:Array.isArray(E)&&"string"==typeof E[0]&&E[0].length>4?T=`${T}\n${E[0].substr(4)}`:e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(E=>{T=`${T}\n${E}\t${e[E]}`}),T},E.httpResponseXml=function httpResponseXml(E,e){let t='<?xml version="1.0" encoding="UTF-8"?><root>';const T=httpResponse(E,e);return Object.keys(T).forEach(E=>{t=`${t}<${E}>${T[E]}</${E}>`}),t+"</root>"},E.httpStatusCode=httpStatusCode,E.httpStatusText=httpStatusText,Object.defineProperty(E,"__esModule",{value:!0})}));
//# sourceMappingURL=http.js.map

@@ -12,3 +12,7 @@ {

],
"dependencies": {},
"dependencies": {
"@babel/plugin-proposal-class-properties": "7.10.1",
"@babel/plugin-proposal-private-methods": "7.10.1",
"rollup": "2.15.0"
},
"description": "Utilities and tools to help build HTTP requests",

@@ -18,5 +22,5 @@ "devDependencies": {

"babel-eslint": "10.1.0",
"eslint": "7.0.0",
"eslint": "7.2.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-jsdoc": "25.4.1",
"eslint-plugin-jsdoc": "27.0.6",
"eslint-plugin-prettier": "3.1.3",

@@ -90,3 +94,3 @@ "jest": "26.0.1",

"types": "./dist/http.d.ts",
"version": "1.0.1"
"version": "1.0.2"
}

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

![CoreFunc](docs/img/logo_128.png?raw=true "CoreFunc")
![CoreFunc](.github/img/logo_128.png?raw=true "CoreFunc")

@@ -124,2 +124,98 @@ # CoreFunc HTTP

## Cheatsheet
### 1XX
```
100 CONTINUE
101 SWITCHING_PROTOCOLS
102 PROCESSING
103 EARLY_HINTS
```
### 2XX
```
200 OK
201 CREATED
202 ACCEPTED
203 NON_AUTHORITATIVE_INFORMATION
204 NO_CONTENT
205 RESET_CONTENT
206 PARTIAL_CONTENT
207 MULTI_STATUS
208 ALREADY_REPORTED
226 IM_USED
```
### 3XX
```
300 MULTIPLE_CHOICES
301 MOVED_PERMANENTLY
302 MOVED_TEMPORARILY
303 SEE_OTHER
304 NOT_MODIFIED
305 USE_PROXY
306 UNUSED
307 TEMPORARY_REDIRECT
308 PERMANENT_REDIRECT
```
### 4XX
```
400 BAD_REQUEST
401 UNAUTHORIZED
402 PAYMENT_REQUIRED
403 FORBIDDEN
404 NOT_FOUND
405 METHOD_NOT_ALLOWED
406 NOT_ACCEPTABLE
407 PROXY_AUTHENTICATION_REQUIRED
408 REQUEST_TIMEOUT
409 CONFLICT
410 GONE
411 LENGTH_REQUIRED
412 PRECONDITION_FAILED
413 PAYLOAD_TOO_LARGE
414 REQUEST_URI_TOO_LONG
415 UNSUPPORTED_MEDIA_TYPE
416 REQUESTED_RANGE_NOT_SATISFIABLE
417 EXPECTATION_FAILED
418 IM_A_TEAPOT
419 INSUFFICIENT_SPACE_ON_RESOURCE
420 ENHANCE_YOUR_CALM
421 MISDIRECTED_REQUEST
422 UNPROCESSABLE_ENTITY
423 export const LOCKED
424 FAILED_DEPENDENCY
425 TOO_EARLY
426 UPGRADE_REQUIRED
428 PRECONDITION_REQUIRED
429 TOO_MANY_REQUESTS
430 WOULD_BLOCK
431 REQUEST_HEADER_FIELDS_TOO_LARGE
451 UNAVAILABLE_FOR_LEGAL_REASONS
```
### 5XX
```
500 INTERNAL_SERVER_ERROR
501 NOT_IMPLEMENTED
502 BAD_GATEWAY
503 SERVICE_UNAVAILABLE
504 GATEWAY_TIMEOUT
505 HTTP_VERSION_NOT_SUPPORTED
506 VARIANT_ALSO_NEGOTIATES
507 INSUFFICIENT_STORAGE
508 LOOP_DETECTED
509 BANDWIDTH_LIMIT_EXCEEDED
510 NOT_EXTENDED
511 NETWORK_AUTHENTICATION_REQUIRED
```
---
## See also

@@ -126,0 +222,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc