urllib
Version:
Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more. Base undici fetch API.
22 lines (18 loc) • 589 B
text/typescript
import { HttpClient, HEADER_USER_AGENT } from './HttpClient';
import { RequestOptions, RequestURL } from './Request';
let httpclient: HttpClient;
export async function request(url: RequestURL, options?: RequestOptions) {
if (!httpclient) {
httpclient = new HttpClient();
}
return await httpclient.request(url, options);
}
export { HttpClient, HEADER_USER_AGENT as USER_AGENT } from './HttpClient';
export {
MockAgent, ProxyAgent, Agent, Dispatcher,
setGlobalDispatcher, getGlobalDispatcher,
} from 'undici';
export default {
request,
USER_AGENT: HEADER_USER_AGENT,
};