Home | History | Annotate | Download | only in url

Lines Matching refs:URL

5 // Package url parses URLs and implements query escaping.
6 package url
22 // Error reports an error and the operation and URL that caused it.
25 URL string
29 func (e *Error) Error() string { return e.Op + " " + e.URL + ": " + e.Err.Error() }
88 return "invalid URL escape " + strconv.Quote(string(e))
98 // appearing in a URL string, according to RFC 3986.
129 // Different sections of the URL allow a few of
188 // which section of the URL string is being unescaped.
268 // inside a URL query.
274 // inside a URL path segment.
316 // A URL represents a parsed URL (technically, a URI reference).
328 // slashes in the raw URL and which were %2f. This distinction is rarely important,
330 // The Parse function sets both Path and RawPath in the URL it returns,
331 // and URL's String method uses RawPath if it is a valid encoding of Path,
333 type URL struct {
364 // password details for a URL. An existing Userinfo value is guaranteed
443 // Parse parses rawurl into a URL structure.
449 func Parse(rawurl string) (*URL, error) {
452 url, err := parse(u, false)
457 return url, nil
459 if url.Fragment, err = unescape(frag, encodeFragment); err != nil {
462 return url, nil
465 // ParseRequestURI parses rawurl into a URL structure. It assumes that
469 // (Web browsers strip #fragment before sending the URL to a web server.)
470 func ParseRequestURI(rawurl string) (*URL, error) {
471 url, err := parse(rawurl, true)
475 return url, nil
478 // parse parses a URL from a string in one of two contexts. If
479 // viaRequest is true, the URL is assumed to have arrived via an HTTP request,
482 func parse(rawurl string, viaRequest bool) (*URL, error) {
487 return nil, errors.New("empty url")
489 url := new(URL)
492 url.Path = "*"
493 return url, nil
498 if url.Scheme, rest, err = getscheme(rawurl); err != nil {
501 url.Scheme = strings.ToLower(url.Scheme)
504 url.ForceQuery = true
507 rest, url.RawQuery = split(rest, "?", true)
511 if url.Scheme != "" {
513 url.Opaque = rest
514 return url, nil
529 // First path segment has colon. Not allowed in relative URL.
530 return nil, errors.New("first path segment in URL cannot contain colon")
534 if (url.Scheme != "" || !viaRequest && !strings.HasPrefix(rest, "///")) && strings.HasPrefix(rest, "//") {
537 url.User, url.Host, err = parseAuthority(authority)
546 if err := url.setPath(rest); err != nil {
549 return url, nil
567 return nil, "", errors.New("net/url: invalid userinfo")
633 // setPath sets the Path and RawPath fields of the URL based on the provided
641 func (u *URL) setPath(p string) error {
665 func (u *URL) EscapedPath() string {
720 // String reassembles the URL into a valid URL string.
740 func (u *URL) String() string {
827 // ParseQuery parses the URL-encoded query string and returns
876 // Encode encodes the values into ``URL encoded'' form
938 // IsAbs reports whether the URL is absolute.
940 func (u *URL) IsAbs() bool {
944 // Parse parses a URL in the context of the receiver. The provided URL
947 func (u *URL) Parse(ref string) (*URL, error) {
958 // URL instance, even if the returned URL is identical to either the
959 // base or reference. If ref is an absolute URL, then ResolveReference
961 func (u *URL) ResolveReference(ref *URL) *URL {
962 url := *ref
964 url.Scheme = u.Scheme
970 url.setPath(resolvePath(ref.EscapedPath(), ""))
971 return &url
974 url.User = nil
975 url.Host = ""
976 url.Path = ""
977 return &url
980 url.RawQuery = u.RawQuery
982 url.Fragment = u.Fragment
986 url.Host = u.Host
987 url.User = u.User
988 url.setPath(resolvePath(u.EscapedPath(), ref.EscapedPath()))
989 return &url
995 func (u *URL) Query() Values {
1002 func (u *URL) RequestURI() string {
1025 func (u *URL) Hostname() string {
1031 func (u *URL) Port() string {
1063 func (u *URL) MarshalBinary() (text []byte, err error) {
1067 func (u *URL) UnmarshalBinary(text []byte) error {