Lines Matching full:url
8 RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter
14 RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zwinski, July 1998.
19 RFC 1738: "Uniform Resource Locators (URL)" by T. Berners-Lee, L. Masinter, M.
137 def urlparse(url, scheme='', allow_fragments=True): argument
138 """Parse a URL into 6 components:
143 tuple = urlsplit(url, scheme, allow_fragments)
144 scheme, netloc, url, query, fragment = tuple
145 if scheme in uses_params and ';' in url:
146 url, params = _splitparams(url)
149 return ParseResult(scheme, netloc, url, params, query, fragment)
151 def _splitparams(url): argument
152 if '/' in url:
153 i = url.find(';', url.rfind('/'))
155 return url, ''
157 i = url.find(';')
158 return url[:i], url[i+1:]
160 def _splitnetloc(url, start=0): argument
161 delim = len(url) # position of end of domain part of url, default is end
163 wdelim = url.find(c, start) # find first of this delim
166 return url[start:delim], url[delim:] # return (domain, rest)
168 def urlsplit(url, scheme='', allow_fragments=True): argument
169 """Parse a URL into 5 components:
175 key = url, scheme, allow_fragments, type(url), type(scheme)
182 i = url.find(':')
184 if url[:i] == 'http': # optimize the common case
185 scheme = url[:i].lower()
186 url = url[i+1:]
187 if url[:2] == '//':
188 netloc, url = _splitnetloc(url, 2)
191 raise ValueError("Invalid IPv6 URL")
192 if allow_fragments and '#' in url:
193 url, fragment = url.split('#', 1)
194 if '?' in url:
195 url, query = url.split('?', 1)
196 v = SplitResult(scheme, netloc, url, query, fragment)
199 for c in url[:i]:
203 # make sure "url" is not actually a port number (in which case
205 rest = url[i+1:]
208 scheme, url = url[:i].lower(), rest
210 if url[:2] == '//':
211 netloc, url = _splitnetloc(url, 2)
214 raise ValueError("Invalid IPv6 URL")
215 if allow_fragments and '#' in url:
216 url, fragment = url.split('#', 1)
217 if '?' in url:
218 url, query = url.split('?', 1)
219 v = SplitResult(scheme, netloc, url, query, fragment)
224 """Put a parsed URL back together again. This may result in a
225 slightly different, but equivalent URL, if the URL that was parsed
228 scheme, netloc, url, params, query, fragment = data
230 url = "%s;%s" % (url, params)
231 return urlunsplit((scheme, netloc, url, query, fragment))
235 complete URL as a string. The data argument can be any five-item iterable.
236 This may result in a slightly different, but equivalent URL, if the URL that
239 scheme, netloc, url, query, fragment = data
240 if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'):
241 if url and url[:1] != '/': url = '/' + url
242 url = '//' + (netloc or '') + url
244 url = scheme + ':' + url
246 url = url + '?' + query
248 url = url + '#' + fragment
249 return url
251 def urljoin(base, url, allow_fragments=True): argument
252 """Join a base URL and a possibly relative URL to form an absolute
255 return url
256 if not url:
261 urlparse(url, bscheme, allow_fragments)
263 return url
303 def urldefrag(url): argument
304 """Removes any existing fragment from URL.
306 Returns a tuple of the defragmented URL and the fragment. If
307 the URL contained no fragments, the second element is the
310 if '#' in url:
311 s, n, p, a, q, frag = urlparse(url)
315 return url, ''