httpquick 1.1.11 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/HttpQuickBase-CYqLvzuS.cjs +1 -0
- package/dist/{HttpQuickBase-BwWho-sN.js → HttpQuickBase-JDE128ZY.js} +5 -3
- package/dist/ajax.js +1 -1
- package/dist/fetch.js +1 -1
- package/dist/fibjs.cjs +1 -1
- package/dist/fibjs.js +1 -1
- package/dist/httpquick.umd.cjs +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/dist/uniapp.js +1 -1
- package/dist/xcx.js +1 -1
- package/package.json +6 -6
- package/dist/HttpQuickBase-MzEqICTi.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class d{config={};middlewares=[];constructor(e={}){Object.assign(this.config,e)}updateConfig(e={}){Object.assign(this.config,e)}addMiddleware(e){this.middlewares.push(e.bind(this))}getDefaultRequest(){return{method:"GET",baseUrl:"",url:"/",headers:{},query:{},json:null,body:null,responseType:"text",dataType:"json",timeout:6e4,fullUrl:""}}getDefaultResponse(){return{status:-1,statusText:"NONE",headers:{},body:null}}obj2query(e){return typeof URLSearchParams<"u"?new URLSearchParams(e).toString():Object.entries(e).map(([t,s])=>encodeURIComponent(t)+"="+encodeURIComponent(s)).join("&")}fillUrl(e){e.fullUrl=(/^https?:\/\//.test(e.url)?e.url:e.baseUrl+e.url)+(e.query&&Object.keys(e.query).length?"?"+this.obj2query(e.query):"")}fillHeaders(e){e.responseType=="text"&&e.dataType=="json"?e.headers.Accept="application/json; charset=utf-8":e.responseType=="text"&&e.dataType=="xml"?e.headers.Accept="application/xml; charset=utf-8":e.responseType=="text"?e.headers.Accept="text/plain; charset=utf-8":(e.responseType=="arraybuffer"||e.responseType=="blob")&&(e.headers.Accept="application/octet-stream")}fillBody(e){(e.method=="POST"||e.method=="PUT")&&(e.filePath||(e.body!==null&&typeof FormData<"u"&&e.body instanceof FormData?typeof process<"u"&&(process?.versions?.node||"0.0.0")!=="0.0.0"&&(e.headers["content-type"]=e.body.getContentType(),e.body=e.body.toStream()):e.body!==null&&typeof URLSearchParams<"u"&&e.body instanceof URLSearchParams?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=e.body.toString()):e.body!==null&&Array.isArray(e.body)?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=e.body.map(t=>encodeURIComponent(t.key)+"="+encodeURIComponent(t.val)).join("&")):e.body!==null&&Object.isObject(e.body)?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=this.obj2query(e.body)):e.json!==null?(e.headers["content-type"]="application/json; charset=utf-8",e.body=JSON.stringify(e.json)):(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body="")))}get(e){return this.request({...e,method:"GET"})}post(e){return this.request({...e,method:"POST"})}put(e){return this.request({...e,method:"PUT"})}del(e){return this.request({...e,method:"DELETE"})}upload(e){return new Error("unreachable")}download(e){return new Error("unreachable")}onTimeoutError=function(e,t,s=null){console.error("http timeout",s),t.status=-4,t.statusText="TIMEOUT",e.responseType=="text"&&e.dataType=="json"?t.body={errno:-1,errmsg:(t.response.status??t.status)+", 网络请求超时!"}:t.body="网络请求超时!"};onNetworkError(e,t,s=null){console.error("http error",s),t.status=-1,t.statusText="NETWORK FAIL",e.responseType=="text"&&e.dataType=="json"?t.body={errno:-2,errmsg:(t.response.status??t.status)+", 网络请求错误!"}:t.body="网络请求错误!"}async request(e){const t=Object.assign(this.getDefaultRequest(),this.config,e);let s=this.getDefaultResponse();t.method=t.method.toUpperCase(),Object.defineProperties(t,{response:{value:s,enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(s,{request:{value:t,enumerable:!1,configurable:!0,writable:!0},response:{value:null,enumerable:!1,configurable:!0,writable:!0},parent:{value:null,enumerable:!1,configurable:!0,writable:!0}});let n=async(o,a)=>{this.fillUrl(o),this.fillHeaders(o),this.fillBody(o),await this.send(o,a)};for(let o=this.middlewares.length-1;o>=0;o--){const a=n,l=this.middlewares[o].bind(this);n=async(i,r)=>await l(i,r,a)}return await n(t,s),s}send(e,t){}install(e,t={}){e.config.globalProperties.$http=this;for(const s in t)this[s]=t[s]}globalMethods(){globalThis.httpGet=this.get.bind(this),globalThis.httpPost=this.post.bind(this),globalThis.httpPut=this.put.bind(this),globalThis.httpDelete=this.del.bind(this),globalThis.httpUpload=this.upload.bind(this),globalThis.httpDownload=this.download.bind(this)}}exports.HttpQuickBase=d;
|
|
@@ -22,7 +22,7 @@ class u {
|
|
|
22
22
|
baseUrl: "",
|
|
23
23
|
url: "/",
|
|
24
24
|
headers: {},
|
|
25
|
-
query:
|
|
25
|
+
query: {},
|
|
26
26
|
json: null,
|
|
27
27
|
body: null,
|
|
28
28
|
responseType: "text",
|
|
@@ -98,8 +98,10 @@ class u {
|
|
|
98
98
|
request: { value: t, enumerable: !1, configurable: !0, writable: !0 },
|
|
99
99
|
response: { value: null, enumerable: !1, configurable: !0, writable: !0 },
|
|
100
100
|
parent: { value: null, enumerable: !1, configurable: !0, writable: !0 }
|
|
101
|
-
})
|
|
102
|
-
let n = async (o, a) =>
|
|
101
|
+
});
|
|
102
|
+
let n = async (o, a) => {
|
|
103
|
+
this.fillUrl(o), this.fillHeaders(o), this.fillBody(o), await this.send(o, a);
|
|
104
|
+
};
|
|
103
105
|
for (let o = this.middlewares.length - 1; o >= 0; o--) {
|
|
104
106
|
const a = n, l = this.middlewares[o].bind(this);
|
|
105
107
|
n = async (i, r) => await l(i, r, a);
|
package/dist/ajax.js
CHANGED
package/dist/fetch.js
CHANGED
package/dist/fibjs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./HttpQuickBase-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./HttpQuickBase-CYqLvzuS.cjs"),d=require("http"),i=require("util");class n extends o.HttpQuickBase{send(e,a){try{const t=d.request(e.method,e.fullUrl,{headers:e.headers,body:e.body||""});a.status=t.statusCode,a.statusText=t.statusMessage;for(let s of t.headers.keys()){const r=t.headers.all(s);s=s.toLowerCase();for(const u of r)a.headers[s]=u}try{e.responseType=="text"&&e.dataType=="json"?a.body=Buffer.isBuffer(t.data)?JSON.parse(t.data.toString("utf8")):typeof t.data=="string"?JSON.parse(t.data):t.data:e.responseType=="text"?a.body=Buffer.isBuffer(t.data)?t.data.toString("utf8"):(typeof t.data=="string",t.data):a.body=t.data}catch{a.body=t.data}}catch(t){return this.onTimeoutError(e,a,t)}}request(e){return i.sync(async a=>await super.request(a))(e)}}exports.HttpQuickBase=o.HttpQuickBase;exports.HttpQuick=n;
|
package/dist/fibjs.js
CHANGED
package/dist/httpquick.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(a,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(a=typeof globalThis<"u"?globalThis:a||self,i(a.httpquick={}))})(this,(function(a){"use strict";class i{config={};middlewares=[];constructor(e={}){Object.assign(this.config,e)}updateConfig(e={}){Object.assign(this.config,e)}addMiddleware(e){this.middlewares.push(e.bind(this))}getDefaultRequest(){return{method:"GET",baseUrl:"",url:"/",headers:{},query:
|
|
1
|
+
(function(a,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(a=typeof globalThis<"u"?globalThis:a||self,i(a.httpquick={}))})(this,(function(a){"use strict";class i{config={};middlewares=[];constructor(e={}){Object.assign(this.config,e)}updateConfig(e={}){Object.assign(this.config,e)}addMiddleware(e){this.middlewares.push(e.bind(this))}getDefaultRequest(){return{method:"GET",baseUrl:"",url:"/",headers:{},query:{},json:null,body:null,responseType:"text",dataType:"json",timeout:6e4,fullUrl:""}}getDefaultResponse(){return{status:-1,statusText:"NONE",headers:{},body:null}}obj2query(e){return typeof URLSearchParams<"u"?new URLSearchParams(e).toString():Object.entries(e).map(([t,o])=>encodeURIComponent(t)+"="+encodeURIComponent(o)).join("&")}fillUrl(e){e.fullUrl=(/^https?:\/\//.test(e.url)?e.url:e.baseUrl+e.url)+(e.query&&Object.keys(e.query).length?"?"+this.obj2query(e.query):"")}fillHeaders(e){e.responseType=="text"&&e.dataType=="json"?e.headers.Accept="application/json; charset=utf-8":e.responseType=="text"&&e.dataType=="xml"?e.headers.Accept="application/xml; charset=utf-8":e.responseType=="text"?e.headers.Accept="text/plain; charset=utf-8":(e.responseType=="arraybuffer"||e.responseType=="blob")&&(e.headers.Accept="application/octet-stream")}fillBody(e){(e.method=="POST"||e.method=="PUT")&&(e.filePath||(e.body!==null&&typeof FormData<"u"&&e.body instanceof FormData?typeof process<"u"&&(process?.versions?.node||"0.0.0")!=="0.0.0"&&(e.headers["content-type"]=e.body.getContentType(),e.body=e.body.toStream()):e.body!==null&&typeof URLSearchParams<"u"&&e.body instanceof URLSearchParams?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=e.body.toString()):e.body!==null&&Array.isArray(e.body)?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=e.body.map(t=>encodeURIComponent(t.key)+"="+encodeURIComponent(t.val)).join("&")):e.body!==null&&Object.isObject(e.body)?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=this.obj2query(e.body)):e.json!==null?(e.headers["content-type"]="application/json; charset=utf-8",e.body=JSON.stringify(e.json)):(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body="")))}get(e){return this.request({...e,method:"GET"})}post(e){return this.request({...e,method:"POST"})}put(e){return this.request({...e,method:"PUT"})}del(e){return this.request({...e,method:"DELETE"})}upload(e){return new Error("unreachable")}download(e){return new Error("unreachable")}onTimeoutError=function(e,t,o=null){console.error("http timeout",o),t.status=-4,t.statusText="TIMEOUT",e.responseType=="text"&&e.dataType=="json"?t.body={errno:-1,errmsg:(t.response.status??t.status)+", 网络请求超时!"}:t.body="网络请求超时!"};onNetworkError(e,t,o=null){console.error("http error",o),t.status=-1,t.statusText="NETWORK FAIL",e.responseType=="text"&&e.dataType=="json"?t.body={errno:-2,errmsg:(t.response.status??t.status)+", 网络请求错误!"}:t.body="网络请求错误!"}async request(e){const t=Object.assign(this.getDefaultRequest(),this.config,e);let o=this.getDefaultResponse();t.method=t.method.toUpperCase(),Object.defineProperties(t,{response:{value:o,enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(o,{request:{value:t,enumerable:!1,configurable:!0,writable:!0},response:{value:null,enumerable:!1,configurable:!0,writable:!0},parent:{value:null,enumerable:!1,configurable:!0,writable:!0}});let l=async(s,n)=>{this.fillUrl(s),this.fillHeaders(s),this.fillBody(s),await this.send(s,n)};for(let s=this.middlewares.length-1;s>=0;s--){const n=l,r=this.middlewares[s].bind(this);l=async(p,h)=>await r(p,h,n)}return await l(t,o),o}send(e,t){}install(e,t={}){e.config.globalProperties.$http=this;for(const o in t)this[o]=t[o]}globalMethods(){globalThis.httpGet=this.get.bind(this),globalThis.httpPost=this.post.bind(this),globalThis.httpPut=this.put.bind(this),globalThis.httpDelete=this.del.bind(this),globalThis.httpUpload=this.upload.bind(this),globalThis.httpDownload=this.download.bind(this)}}class d extends i{send(e,t){let o=null,l=new Promise(n=>o=n);const s=t.response=new XMLHttpRequest;s.open(e.method,e.fullUrl,!0),s.timeout=e.timeout,s.withCredentials=e.withCredentials||!1,s.responseType=e.responseType;for(const[n,r]of Object.entries(e.headers))s.setRequestHeader(n,r);return s.ontimeout=n=>{this.onTimeoutError(e,t,n),o()},s.onerror=n=>{this.onNetworkError(e,t,n),o()},e.onprocess&&s.upload.addEventListener("progress",e.onprocess),s.onreadystatechange=()=>{if(!(s.readyState!==4||s.status==0)){t.status=s.status,t.statusText=s.statusText,t.headers=Object.fromEntries(s.getAllResponseHeaders().trim().replaceAll("\r","").split(`
|
|
2
2
|
`).map(n=>[decodeURIComponent(n.substring(0,n.indexOf(": ")).toLowerCase()),decodeURIComponent(n.substring(n.indexOf(": ")+2))]));try{e.responseType=="text"&&e.dataType=="json"?t.body=JSON.parse(s.responseText):e.responseType=="text"?t.body=s.responseText:t.body=s.response}catch{t.body=s.response}o()}},e.method=="POST"||e.method=="PUT"?s.send(e.body):s.send(),l}}a.HttpQuick=d,a.HttpQuickBase=i,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/node.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./HttpQuickBase-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./HttpQuickBase-CYqLvzuS.cjs");class p extends r.HttpQuickBase{send(t,o){let n=null,a=new Promise(s=>n=s);const e=o.response=new XMLHttpRequest;e.open(t.method,t.fullUrl,!0),e.timeout=t.timeout,e.withCredentials=t.withCredentials||!1,e.responseType=t.responseType;for(const[s,i]of Object.entries(t.headers))e.setRequestHeader(s,i);return e.ontimeout=s=>{this.onTimeoutError(t,o,s),n()},e.onerror=s=>{this.onNetworkError(t,o,s),n()},t.onprocess&&e.upload.addEventListener("progress",t.onprocess),e.onreadystatechange=()=>{if(!(e.readyState!==4||e.status==0)){o.status=e.status,o.statusText=e.statusText,o.headers=Object.fromEntries(e.getAllResponseHeaders().trim().replaceAll("\r","").split(`
|
|
2
2
|
`).map(s=>[decodeURIComponent(s.substring(0,s.indexOf(": ")).toLowerCase()),decodeURIComponent(s.substring(s.indexOf(": ")+2))]));try{t.responseType=="text"&&t.dataType=="json"?o.body=JSON.parse(e.responseText):t.responseType=="text"?o.body=e.responseText:o.body=e.response}catch{o.body=e.response}n()}},t.method=="POST"||t.method=="PUT"?e.send(t.body):e.send(),a}}exports.HttpQuickBase=r.HttpQuickBase;exports.HttpQuick=p;
|
package/dist/node.js
CHANGED
package/dist/uniapp.js
CHANGED
package/dist/xcx.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "httpquick",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"description": "js http quick request",
|
|
5
5
|
"author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
|
|
6
6
|
"homepage": "https://github.com/dotcoo/httpquick#readme",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"preview": "vite preview"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
55
|
-
"pinia": "^3.0.
|
|
56
|
-
"vite": "^7.
|
|
57
|
-
"vue": "^3.5.
|
|
58
|
-
"vue-router": "^4.
|
|
54
|
+
"@vitejs/plugin-vue": "^6.0.2",
|
|
55
|
+
"pinia": "^3.0.4",
|
|
56
|
+
"vite": "^7.2.4",
|
|
57
|
+
"vue": "^3.5.25",
|
|
58
|
+
"vue-router": "^4.6.3"
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";class d{config={};middlewares=[];constructor(e={}){Object.assign(this.config,e)}updateConfig(e={}){Object.assign(this.config,e)}addMiddleware(e){this.middlewares.push(e.bind(this))}getDefaultRequest(){return{method:"GET",baseUrl:"",url:"/",headers:{},query:null,json:null,body:null,responseType:"text",dataType:"json",timeout:6e4,fullUrl:""}}getDefaultResponse(){return{status:-1,statusText:"NONE",headers:{},body:null}}obj2query(e){return typeof URLSearchParams<"u"?new URLSearchParams(e).toString():Object.entries(e).map(([t,s])=>encodeURIComponent(t)+"="+encodeURIComponent(s)).join("&")}fillUrl(e){e.fullUrl=(/^https?:\/\//.test(e.url)?e.url:e.baseUrl+e.url)+(e.query&&Object.keys(e.query).length?"?"+this.obj2query(e.query):"")}fillHeaders(e){e.responseType=="text"&&e.dataType=="json"?e.headers.Accept="application/json; charset=utf-8":e.responseType=="text"&&e.dataType=="xml"?e.headers.Accept="application/xml; charset=utf-8":e.responseType=="text"?e.headers.Accept="text/plain; charset=utf-8":(e.responseType=="arraybuffer"||e.responseType=="blob")&&(e.headers.Accept="application/octet-stream")}fillBody(e){(e.method=="POST"||e.method=="PUT")&&(e.filePath||(e.body!==null&&typeof FormData<"u"&&e.body instanceof FormData?typeof process<"u"&&(process?.versions?.node||"0.0.0")!=="0.0.0"&&(e.headers["content-type"]=e.body.getContentType(),e.body=e.body.toStream()):e.body!==null&&typeof URLSearchParams<"u"&&e.body instanceof URLSearchParams?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=e.body.toString()):e.body!==null&&Array.isArray(e.body)?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=e.body.map(t=>encodeURIComponent(t.key)+"="+encodeURIComponent(t.val)).join("&")):e.body!==null&&Object.isObject(e.body)?(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body=this.obj2query(e.body)):e.json!==null?(e.headers["content-type"]="application/json; charset=utf-8",e.body=JSON.stringify(e.json)):(e.headers["content-type"]="application/x-www-form-urlencoded; charset=utf-8",e.body="")))}get(e){return this.request({...e,method:"GET"})}post(e){return this.request({...e,method:"POST"})}put(e){return this.request({...e,method:"PUT"})}del(e){return this.request({...e,method:"DELETE"})}upload(e){return new Error("unreachable")}download(e){return new Error("unreachable")}onTimeoutError=function(e,t,s=null){console.error("http timeout",s),t.status=-4,t.statusText="TIMEOUT",e.responseType=="text"&&e.dataType=="json"?t.body={errno:-1,errmsg:(t.response.status??t.status)+", 网络请求超时!"}:t.body="网络请求超时!"};onNetworkError(e,t,s=null){console.error("http error",s),t.status=-1,t.statusText="NETWORK FAIL",e.responseType=="text"&&e.dataType=="json"?t.body={errno:-2,errmsg:(t.response.status??t.status)+", 网络请求错误!"}:t.body="网络请求错误!"}async request(e){const t=Object.assign(this.getDefaultRequest(),this.config,e);let s=this.getDefaultResponse();t.method=t.method.toUpperCase(),Object.defineProperties(t,{response:{value:s,enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(s,{request:{value:t,enumerable:!1,configurable:!0,writable:!0},response:{value:null,enumerable:!1,configurable:!0,writable:!0},parent:{value:null,enumerable:!1,configurable:!0,writable:!0}}),this.fillUrl(t),this.fillHeaders(t),this.fillBody(t);let n=async(o,a)=>await this.send(o,a);for(let o=this.middlewares.length-1;o>=0;o--){const a=n,l=this.middlewares[o].bind(this);n=async(i,r)=>await l(i,r,a)}return await n(t,s),s}send(e,t){}install(e,t={}){e.config.globalProperties.$http=this;for(const s in t)this[s]=t[s]}globalMethods(){globalThis.httpGet=this.get.bind(this),globalThis.httpPost=this.post.bind(this),globalThis.httpPut=this.put.bind(this),globalThis.httpDelete=this.del.bind(this),globalThis.httpUpload=this.upload.bind(this),globalThis.httpDownload=this.download.bind(this)}}exports.HttpQuickBase=d;
|