Python urllib.request.has_proxy() Examples
The following are 30
code examples of urllib.request.has_proxy().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
urllib.request
, or try the search function
.
Example #1
Source File: request.py From Imogen with MIT License | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #2
Source File: request.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #3
Source File: request.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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
Example #4
Source File: request.py From blackmamba with MIT License | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #5
Source File: request.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #6
Source File: request.py From addon with GNU General Public License v3.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #7
Source File: request.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #8
Source File: request.py From ironpython3 with Apache License 2.0 | 5 votes |
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
Example #9
Source File: request.py From ironpython3 with Apache License 2.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #10
Source File: request.py From arissploit with GNU General Public License v3.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #11
Source File: request.py From telegram-robot-rss with Mozilla Public License 2.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #12
Source File: request.py From Imogen with MIT License | 5 votes |
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
Example #13
Source File: request.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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
Example #14
Source File: request.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #15
Source File: request.py From kgsgo-dataset-preprocessor with Mozilla Public License 2.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #16
Source File: request.py From Tautulli with GNU General Public License v3.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #17
Source File: request.py From deepWordBug with Apache License 2.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #18
Source File: request.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #19
Source File: request.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #20
Source File: request.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #21
Source File: request.py From verge3d-blender-addon with GNU General Public License v3.0 | 5 votes |
def has_proxy(self): return self.selector == self.full_url
Example #22
Source File: request.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 4 votes |
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
Example #23
Source File: request.py From arissploit with GNU General Public License v3.0 | 4 votes |
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
Example #24
Source File: request.py From gimp-plugin-export-layers with GNU General Public License v3.0 | 4 votes |
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
Example #25
Source File: request.py From Tautulli with GNU General Public License v3.0 | 4 votes |
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
Example #26
Source File: request.py From blackmamba with MIT License | 4 votes |
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
Example #27
Source File: request.py From addon with GNU General Public License v3.0 | 4 votes |
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
Example #28
Source File: request.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 4 votes |
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
Example #29
Source File: request.py From telegram-robot-rss with Mozilla Public License 2.0 | 4 votes |
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
Example #30
Source File: request.py From kgsgo-dataset-preprocessor with Mozilla Public License 2.0 | 4 votes |
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