@nxtedition/nxt-undici 7.2.7 → 7.2.9
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/lib/index.js +7 -26
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -104,34 +104,15 @@ function wrapDispatch(dispatcher) {
|
|
|
104
104
|
|
|
105
105
|
const headers = parseHeaders(opts.headers)
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
headers['user-agent'] ??=
|
|
107
|
+
const userAgent =
|
|
109
108
|
opts.userAgent ?? globalThis.userAgent ?? globalThis.__nxt_undici_user_agent
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// Do nothing
|
|
114
|
-
} else if (opts.priority === 'low' || opts.priority === 0 || opts.priority === '0') {
|
|
115
|
-
headers['nxt-priority'] = 'low'
|
|
116
|
-
priority = 0
|
|
117
|
-
} else if (opts.priority === 'normal' || opts.priority === 1 || opts.priority === '1') {
|
|
118
|
-
headers['nxt-priority'] = 'normal'
|
|
119
|
-
priority = 1
|
|
120
|
-
} else if (opts.priority === 'high' || opts.priority === 2 || opts.priority === '2') {
|
|
121
|
-
headers['nxt-priority'] = 'high'
|
|
122
|
-
priority = 2
|
|
123
|
-
} else {
|
|
124
|
-
throw new TypeError('invalid opts.priority')
|
|
109
|
+
if (userAgent != null) {
|
|
110
|
+
headers['user-agent'] ??=
|
|
111
|
+
opts.userAgent ?? globalThis.userAgent ?? globalThis.__nxt_undici_user_agent
|
|
125
112
|
}
|
|
126
113
|
|
|
127
|
-
if (priority
|
|
128
|
-
|
|
129
|
-
priority = 0
|
|
130
|
-
} else if (headers['nxt-priority'] === 'normal' || headers['nxt-priority'] === '1') {
|
|
131
|
-
priority = 1
|
|
132
|
-
} else if (headers['nxt-priority'] === 'high' || headers['nxt-priority'] === '2') {
|
|
133
|
-
priority = 2
|
|
134
|
-
}
|
|
114
|
+
if (opts.priority != null) {
|
|
115
|
+
headers['nxt-priority'] = String(opts.priority)
|
|
135
116
|
}
|
|
136
117
|
|
|
137
118
|
if (globalThis.__nxt_undici_global_headers) {
|
|
@@ -164,7 +145,7 @@ function wrapDispatch(dispatcher) {
|
|
|
164
145
|
logger: opts.logger ?? null,
|
|
165
146
|
dns: opts.dns ?? true,
|
|
166
147
|
connect: opts.connect,
|
|
167
|
-
priority,
|
|
148
|
+
priority: opts.priority ?? headers['nxt-priority'],
|
|
168
149
|
lookup: opts.lookup ?? defaultLookup,
|
|
169
150
|
},
|
|
170
151
|
handler,
|