當前位置: 首頁>>代碼示例>>Python>>正文


Python request.has_proxy方法代碼示例

本文整理匯總了Python中urllib.request.has_proxy方法的典型用法代碼示例。如果您正苦於以下問題:Python request.has_proxy方法的具體用法?Python request.has_proxy怎麽用?Python request.has_proxy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urllib.request的用法示例。


在下文中一共展示了request.has_proxy方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: has_proxy

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import has_proxy [as 別名]
def has_proxy(self):
        return self.selector == self.full_url 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:4,代碼來源:request.py

示例2: do_request_

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import has_proxy [as 別名]
def do_request_(self, request):
        host = request.host
        if not host:
            raise URLError('no host given')

        if request.data is not None:  # POST
            data = request.data
            if isinstance(data, str):
                msg = "POST data should be bytes or an iterable of bytes. " \
                      "It cannot be of type str."
                raise TypeError(msg)
            if not request.has_header('Content-type'):
                request.add_unredirected_header(
                    'Content-type',
                    'application/x-www-form-urlencoded')
            if not request.has_header('Content-length'):
                try:
                    mv = memoryview(data)
                except TypeError:
                    if isinstance(data, collections.Iterable):
                        raise ValueError("Content-Length should be specified "
                                "for iterable data of type %r %r" % (type(data),
                                data))
                else:
                    request.add_unredirected_header(
                            'Content-length', '%d' % (len(mv) * mv.itemsize))

        sel_host = host
        if request.has_proxy():
            scheme, sel = splittype(request.selector)
            sel_host, sel_path = splithost(sel)
        if not request.has_header('Host'):
            request.add_unredirected_header('Host', sel_host)
        for name, value in self.parent.addheaders:
            name = name.capitalize()
            if not request.has_header(name):
                request.add_unredirected_header(name, value)

        return request 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:41,代碼來源:request.py

示例3: do_request_

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import has_proxy [as 別名]
def do_request_(self, request):
        host = request.host
        if not host:
            raise URLError('no host given')

        if request.data is not None:  # POST
            data = request.data
            if isinstance(data, str):
                msg = "POST data should be bytes, an iterable of bytes, " \
                      "or a file object. It cannot be of type str."
                raise TypeError(msg)
            if not request.has_header('Content-type'):
                request.add_unredirected_header(
                    'Content-type',
                    'application/x-www-form-urlencoded')
            if (not request.has_header('Content-length')
                    and not request.has_header('Transfer-encoding')):
                content_length = self._get_content_length(request)
                if content_length is not None:
                    request.add_unredirected_header(
                            'Content-length', str(content_length))
                else:
                    request.add_unredirected_header(
                            'Transfer-encoding', 'chunked')

        sel_host = host
        if request.has_proxy():
            scheme, sel = splittype(request.selector)
            sel_host, sel_path = splithost(sel)
        if not request.has_header('Host'):
            request.add_unredirected_header('Host', sel_host)
        for name, value in self.parent.addheaders:
            name = name.capitalize()
            if not request.has_header(name):
                request.add_unredirected_header(name, value)

        return request 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:39,代碼來源:request.py

示例4: do_request_

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import has_proxy [as 別名]
def do_request_(self, request):
        host = request.host
        if not host:
            raise URLError('no host given')

        if request.data is not None:  # POST
            data = request.data
            if isinstance(data, str):
                msg = "POST data should be bytes or an iterable of bytes. " \
                      "It cannot be of type str."
                raise TypeError(msg)
            if not request.has_header('Content-type'):
                request.add_unredirected_header(
                    'Content-type',
                    'application/x-www-form-urlencoded')
            if not request.has_header('Content-length'):
                size = None
                try:
                    ### For Python-Future:
                    if PY2 and isinstance(data, array.array):
                        # memoryviews of arrays aren't supported
                        # in Py2.7. (e.g. memoryview(array.array('I',
                        # [1, 2, 3, 4])) raises a TypeError.)
                        # So we calculate the size manually instead:
                        size = len(data) * data.itemsize
                    ###
                    else:
                        mv = memoryview(data)
                        size = len(mv) * mv.itemsize
                except TypeError:
                    if isinstance(data, collections.Iterable):
                        raise ValueError("Content-Length should be specified "
                                "for iterable data of type %r %r" % (type(data),
                                data))
                else:
                    request.add_unredirected_header(
                            'Content-length', '%d' % size)

        sel_host = host
        if request.has_proxy():
            scheme, sel = splittype(request.selector)
            sel_host, sel_path = splithost(sel)
        if not request.has_header('Host'):
            request.add_unredirected_header('Host', sel_host)
        for name, value in self.parent.addheaders:
            name = name.capitalize()
            if not request.has_header(name):
                request.add_unredirected_header(name, value)

        return request 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:52,代碼來源:request.py

示例5: do_request_

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import has_proxy [as 別名]
def do_request_(self, request):
        host = request.host
        if not host:
            raise URLError('no host given')

        if request.data is not None:  # POST
            data = request.data
            if isinstance(data, str):
                msg = "POST data should be bytes or an iterable of bytes. " \
                      "It cannot be of type str."
                raise TypeError(msg)
            if not request.has_header('Content-type'):
                request.add_unredirected_header(
                    'Content-type',
                    'application/x-www-form-urlencoded')
            if not request.has_header('Content-length'):
                size = None
                try:
                    ### For Python-Future:
                    if PY2 and isinstance(data, array.array):
                        # memoryviews of arrays aren't supported
                        # in Py2.7. (e.g. memoryview(array.array('I',
                        # [1, 2, 3, 4])) raises a TypeError.)
                        # So we calculate the size manually instead:
                        size = len(data) * data.itemsize
                    ###
                    else:
                        mv = memoryview(data)
                        size = len(mv) * mv.itemsize
                except TypeError:
                    if isinstance(data, Iterable):
                        raise ValueError("Content-Length should be specified "
                                "for iterable data of type %r %r" % (type(data),
                                data))
                else:
                    request.add_unredirected_header(
                            'Content-length', '%d' % size)

        sel_host = host
        if request.has_proxy():
            scheme, sel = splittype(request.selector)
            sel_host, sel_path = splithost(sel)
        if not request.has_header('Host'):
            request.add_unredirected_header('Host', sel_host)
        for name, value in self.parent.addheaders:
            name = name.capitalize()
            if not request.has_header(name):
                request.add_unredirected_header(name, value)

        return request 
開發者ID:alfa-addon,項目名稱:addon,代碼行數:52,代碼來源:request.py


注:本文中的urllib.request.has_proxy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。