2019-11-01 22:33:28 +03:00
|
|
|
# Portions Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
|
|
|
|
2017-10-01 17:45:03 +03:00
|
|
|
# urllibcompat.py - adapters to ease using urllib2 on Py2 and urllib on Py3
|
|
|
|
#
|
|
|
|
# Copyright 2017 Google, Inc.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2019-12-05 04:02:25 +03:00
|
|
|
import sys
|
|
|
|
|
2017-10-01 17:45:03 +03:00
|
|
|
from . import pycompat
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-10-04 18:58:00 +03:00
|
|
|
_sysstr = pycompat.sysstr
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-10-04 18:58:00 +03:00
|
|
|
class _pycompatstub(object):
|
|
|
|
def __init__(self):
|
|
|
|
self._aliases = {}
|
|
|
|
|
|
|
|
def _registeraliases(self, origin, items):
|
|
|
|
"""Add items that will be populated at the first access"""
|
2020-01-29 05:22:50 +03:00
|
|
|
items = list(map(_sysstr, items))
|
2017-10-04 18:58:00 +03:00
|
|
|
self._aliases.update(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
(item.replace(_sysstr("_"), _sysstr("")).lower(), (origin, item))
|
|
|
|
for item in items
|
|
|
|
)
|
2017-10-04 18:58:00 +03:00
|
|
|
|
|
|
|
def _registeralias(self, origin, attr, name):
|
|
|
|
"""Alias ``origin``.``attr`` as ``name``"""
|
|
|
|
self._aliases[_sysstr(name)] = (origin, _sysstr(attr))
|
|
|
|
|
|
|
|
def __getattr__(self, name):
|
|
|
|
try:
|
|
|
|
origin, item = self._aliases[name]
|
|
|
|
except KeyError:
|
|
|
|
raise AttributeError(name)
|
|
|
|
self.__dict__[name] = obj = getattr(origin, item)
|
|
|
|
return obj
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-10-04 18:58:00 +03:00
|
|
|
httpserver = _pycompatstub()
|
|
|
|
urlreq = _pycompatstub()
|
|
|
|
urlerr = _pycompatstub()
|
|
|
|
|
2019-12-05 04:02:25 +03:00
|
|
|
if sys.version_info[0] >= 3:
|
2017-10-04 18:58:00 +03:00
|
|
|
import urllib.parse
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
urlreq._registeraliases(
|
|
|
|
urllib.parse,
|
|
|
|
(
|
|
|
|
"splitattr",
|
|
|
|
"splitpasswd",
|
|
|
|
"splitport",
|
|
|
|
"splituser",
|
|
|
|
"urlparse",
|
|
|
|
"urlunparse",
|
|
|
|
),
|
|
|
|
)
|
2020-01-28 21:21:58 +03:00
|
|
|
urlreq._registeralias(urllib.parse, "unquote", "unquote")
|
2017-10-04 18:58:00 +03:00
|
|
|
import urllib.request
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
urlreq._registeraliases(
|
|
|
|
urllib.request,
|
|
|
|
(
|
|
|
|
"AbstractHTTPHandler",
|
|
|
|
"BaseHandler",
|
|
|
|
"build_opener",
|
|
|
|
"FileHandler",
|
|
|
|
"FTPHandler",
|
|
|
|
"ftpwrapper",
|
|
|
|
"HTTPHandler",
|
|
|
|
"HTTPSHandler",
|
|
|
|
"install_opener",
|
|
|
|
"pathname2url",
|
|
|
|
"HTTPBasicAuthHandler",
|
|
|
|
"HTTPDigestAuthHandler",
|
|
|
|
"HTTPPasswordMgrWithDefaultRealm",
|
|
|
|
"ProxyHandler",
|
|
|
|
"Request",
|
|
|
|
"url2pathname",
|
|
|
|
"urlopen",
|
|
|
|
),
|
|
|
|
)
|
2017-10-04 18:58:00 +03:00
|
|
|
import urllib.response
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
urlreq._registeraliases(urllib.response, ("addclosehook", "addinfourl"))
|
2017-10-04 18:58:00 +03:00
|
|
|
import urllib.error
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
urlerr._registeraliases(urllib.error, ("HTTPError", "URLError"))
|
2017-10-04 18:58:00 +03:00
|
|
|
import http.server
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
httpserver._registeraliases(
|
|
|
|
http.server,
|
|
|
|
(
|
|
|
|
"HTTPServer",
|
|
|
|
"BaseHTTPRequestHandler",
|
|
|
|
"SimpleHTTPRequestHandler",
|
|
|
|
"CGIHTTPRequestHandler",
|
|
|
|
),
|
|
|
|
)
|
2017-10-04 18:58:00 +03:00
|
|
|
|
|
|
|
# urllib.parse.quote() accepts both str and bytes, decodes bytes
|
|
|
|
# (if necessary), and returns str. This is wonky. We provide a custom
|
|
|
|
# implementation that only accepts bytes and emits bytes.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
def quote(s, safe=r"/"):
|
2020-01-28 21:21:58 +03:00
|
|
|
s = urllib.parse.quote(s, safe=safe)
|
|
|
|
return s
|
2017-10-04 18:58:00 +03:00
|
|
|
|
|
|
|
# urllib.parse.urlencode() returns str. We use this function to make
|
|
|
|
# sure we return bytes.
|
|
|
|
def urlencode(query, doseq=False):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
s = urllib.parse.urlencode(query, doseq=doseq)
|
2020-01-28 21:21:58 +03:00
|
|
|
return s
|
2017-10-04 18:58:00 +03:00
|
|
|
|
2019-12-04 21:53:06 +03:00
|
|
|
# pyre-fixme[16]: `_pycompatstub` has no attribute `quote`.
|
2017-10-04 18:58:00 +03:00
|
|
|
urlreq.quote = quote
|
2019-12-04 21:53:06 +03:00
|
|
|
# pyre-fixme[16]: `_pycompatstub` has no attribute `urlencode`.
|
2017-10-04 18:58:00 +03:00
|
|
|
urlreq.urlencode = urlencode
|
2017-10-01 17:45:03 +03:00
|
|
|
|
|
|
|
def getfullurl(req):
|
|
|
|
return req.full_url
|
|
|
|
|
|
|
|
def gethost(req):
|
|
|
|
return req.host
|
|
|
|
|
|
|
|
def getselector(req):
|
|
|
|
return req.selector
|
|
|
|
|
|
|
|
def getdata(req):
|
|
|
|
return req.data
|
|
|
|
|
|
|
|
def hasdata(req):
|
|
|
|
return req.data is not None
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
|
2017-10-01 17:45:03 +03:00
|
|
|
else:
|
2017-10-04 18:58:00 +03:00
|
|
|
import BaseHTTPServer
|
2019-12-04 21:53:06 +03:00
|
|
|
|
2017-10-04 18:58:00 +03:00
|
|
|
import CGIHTTPServer
|
2019-12-04 21:53:06 +03:00
|
|
|
|
2017-10-04 18:58:00 +03:00
|
|
|
import SimpleHTTPServer
|
2019-12-04 21:53:06 +03:00
|
|
|
|
2017-10-04 18:58:00 +03:00
|
|
|
import urllib2
|
|
|
|
import urllib
|
2019-12-04 21:53:06 +03:00
|
|
|
|
2017-10-04 18:58:00 +03:00
|
|
|
import urlparse
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
urlreq._registeraliases(
|
|
|
|
urllib,
|
|
|
|
(
|
|
|
|
"addclosehook",
|
|
|
|
"addinfourl",
|
|
|
|
"ftpwrapper",
|
|
|
|
"pathname2url",
|
|
|
|
"quote",
|
|
|
|
"splitattr",
|
|
|
|
"splitpasswd",
|
|
|
|
"splitport",
|
|
|
|
"splituser",
|
|
|
|
"unquote",
|
|
|
|
"url2pathname",
|
|
|
|
"urlencode",
|
|
|
|
),
|
|
|
|
)
|
|
|
|
urlreq._registeraliases(
|
|
|
|
urllib2,
|
|
|
|
(
|
|
|
|
"AbstractHTTPHandler",
|
|
|
|
"BaseHandler",
|
|
|
|
"build_opener",
|
|
|
|
"FileHandler",
|
|
|
|
"FTPHandler",
|
|
|
|
"HTTPBasicAuthHandler",
|
|
|
|
"HTTPDigestAuthHandler",
|
|
|
|
"HTTPHandler",
|
|
|
|
"HTTPPasswordMgrWithDefaultRealm",
|
|
|
|
"HTTPSHandler",
|
|
|
|
"install_opener",
|
|
|
|
"ProxyHandler",
|
|
|
|
"Request",
|
|
|
|
"urlopen",
|
|
|
|
),
|
|
|
|
)
|
|
|
|
urlreq._registeraliases(urlparse, ("urlparse", "urlunparse"))
|
|
|
|
urlerr._registeraliases(urllib2, ("HTTPError", "URLError"))
|
|
|
|
httpserver._registeraliases(
|
|
|
|
BaseHTTPServer, ("HTTPServer", "BaseHTTPRequestHandler")
|
|
|
|
)
|
|
|
|
httpserver._registeraliases(SimpleHTTPServer, ("SimpleHTTPRequestHandler",))
|
|
|
|
httpserver._registeraliases(CGIHTTPServer, ("CGIHTTPRequestHandler",))
|
2017-10-01 17:45:03 +03:00
|
|
|
|
|
|
|
def gethost(req):
|
|
|
|
return req.get_host()
|
|
|
|
|
|
|
|
def getselector(req):
|
|
|
|
return req.get_selector()
|
|
|
|
|
|
|
|
def getfullurl(req):
|
|
|
|
return req.get_full_url()
|
|
|
|
|
|
|
|
def getdata(req):
|
|
|
|
return req.get_data()
|
|
|
|
|
|
|
|
def hasdata(req):
|
|
|
|
return req.has_data()
|