温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/url/urlToHttpOptions
点击访问原文链接

Node url.urlToHttpOptions function | API Reference | Bun

Node url.urlToHttpOptions function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:url/urlToHttpOptionsFurlToHttpOptions

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:url/urlToHttpOptionsFurlToHttpOptions

function

url.urlToHttpOptionsfunction urlToHttpOptions(url: URL): ClientRequestArgs;

This utility function converts a URL object into an ordinary options object as expected by the http.request() and https.request() APIs.

import { urlToHttpOptions } from 'node:url';
const myURL = new URL('https://a:b@測試?abc#foo');

console.log(urlToHttpOptions(myURL));
/*
{
protocol: 'https:',
hostname: 'xn--g6w251d',
hash: '#foo',
search: '?abc',
pathname: '/',
path: '/?abc',
href: 'https://a:b@xn--g6w251d/?abc#foo',
auth: 'a:b'
}

@param url

The WHATWG URL object to convert to an options object.

@returns

Options object

Referenced typesinterface URLhash: stringhost: stringhostname: stringhref: stringreadonly origin: stringpassword: stringpathname: stringport: stringprotocol: stringsearch: stringreadonly searchParams: URLSearchParamsusername: stringtoJSON(): string;interface ClientRequestArgs_defaultAgent?: Agentagent?: boolean | Agentauth?: null | stringcreateConnection?: (options: ClientRequestArgs, oncreate: (err: null | Error, socket: Duplex) => void) => undefined | null | DuplexdefaultPort?: string | numberfamily?: numberheaders?: readonly string[] | OutgoingHttpHeadershints?: numberhost?: null | stringhostname?: null | stringinsecureHTTPParser?: booleanjoinDuplicateHeaders?: booleanlocalAddress?: stringlocalPort?: numberlookup?: LookupFunctionmaxHeaderSize?: number
method?: stringpath?: null | stringport?: null | string | numberprotocol?: null | stringsetDefaultHeaders?: booleansetHost?: booleansignal?: AbortSignalsocketPath?: stringtimeout?: numberuniqueHeaders?: string | string[][]

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

Node url.urlToHttpOptions function | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for function node:url.urlToHttpOptions | Bun