1 | // src/internal/request.ts
|
2 | function n(e) {
|
3 | let r, o, a, t = {};
|
4 | for ([r, o] of e)
|
5 | t[r] = (a = t[r]) !== void 0 ? [].concat(a, o) : o;
|
6 | return t;
|
7 | }
|
8 | async function i(e, r) {
|
9 | if (!(!e.body || !r))
|
10 | return ~r.indexOf("application/json") ? e.json() : ~r.indexOf("multipart/form-data") || ~r.indexOf("application/x-www-form-urlencoded") ? e.formData().then(n) : ~r.indexOf("text/") ? e.text() : e.arrayBuffer();
|
11 | }
|
12 |
|
13 | // src/request.ts
|
14 | function f(e) {
|
15 | let {request: r, waitUntil: o} = e, a = new URL(r.url), t = this;
|
16 | return t.url = r.url, t.method = r.method, t.headers = r.headers, t.extend = o, t.cf = r.cf, t.params = {}, t.path = a.pathname, t.hostname = a.hostname, t.origin = a.origin, t.query = a.searchParams, t.search = a.search, t.body = i.bind(0, r, t.headers.get("content-type")), t.body.blob = r.blob.bind(r), t.body.text = r.text.bind(r), t.body.arrayBuffer = r.arrayBuffer.bind(r), t.body.formData = r.formData.bind(r), t.body.json = r.json.bind(r), t;
|
17 | }
|
18 |
|
19 |
|
20 | exports.ServerRequest = f; |
\ | No newline at end of file |