My favorites
▼
|
Sign in
gphotoframe
Photo Frame Gadget
Project Home
Downloads
Wiki
Issues
Source
Repository:
default
wiki
Checkout
Browse
Changes
Clones
Source path:
hg
/
lib
/
utils
/
urlget.py
Branch:
0.7_stable
bijin
clutter
default
stable
0.5_stable (closed)
0.6_stable (closed)
1.0_stable (closed)
1.1_stable (closed)
1.2_stable (closed)
1.3_stable (closed)
1.4_stable (closed)
base_plugin (closed)
facebook (closed)
flickr_auth (closed)
flickr_nsid (closed)
gconf_schemas (closed)
gtkbuilder (closed)
help (closed)
history (closed)
pacparser (closed)
photoimage_pixbuf (closed)
photosource_tooltip (closed)
plugin_check (closed)
pygi (closed)
source_icon (closed)
trash (closed)
tumblr_dashboard (closed)
Tag:
<none>
0.1
0.2
0.2.1
0.3
0.3.1
0.4
0.4.1
0.5
0.6
0.6.1
0.7
0.7.1
0.7.2
1.2
1.5
‹ddb33d6a6895
c6189be818cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright (c) 2001-2008 Twisted Matrix Laboratories.
# Copyright (c) 2009-2011 Yoshizumi Endo.
#
# This urlget is a modified version of twisted.web.client module.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
HTTP Client with proxy support.
"""
import os
from twisted.web import client
from twisted.internet import reactor
class UrlGetWithProxy(object):
def __init__(self, proxy=None):
if proxy is None:
proxy = os.environ.get('http_proxy') or ""
self.proxy_host, self.proxy_port = client._parse(proxy)[1:3]
self.use_proxy = bool(self.proxy_host and self.proxy_port)
def getPage(self, url, contextFactory=None, *args, **kwargs):
factory = client.HTTPClientFactory(url, *args, **kwargs)
d = self._urlget(factory, url, contextFactory)
return d
def downloadPage(self, url, file, contextFactory=None, *args, **kwargs):
factory = client.HTTPDownloader(url, file, *args, **kwargs)
d = self._urlget(factory, url, contextFactory)
return d
def _urlget(self, factory, url, contextFactory=None):
scheme, host, port, path = client._parse(url)
if self.use_proxy and scheme != 'https': # HTTPS proxy isn't supported.
host, port = self.proxy_host, self.proxy_port
factory.path = url
if scheme == 'https':
from twisted.internet import ssl
if contextFactory is None:
contextFactory = ssl.ClientContextFactory()
reactor.connectSSL(host, port, factory, contextFactory)
else:
reactor.connectTCP(host, port, factory)
return factory.deferred
Show details
Hide details
Change log
09eb9764c19d
by yendo0206 on Dec 7, 2011
Diff
Code refactoring.
Go to:
/lib/dbus/networkstate.py
/lib/frame.py
/lib/menu.py
/lib/plugins/base/base.py
/lib/plugins/base/ui.py
/lib/plugins/haikyo.py
/lib/plugins/picasa.py
/lib/plugins/tumblr/ui.py
/lib/preferences/plugin.py
/lib/utils/autostart.py
/lib/utils/sqldb.py
/lib/utils/urlget.py
Project members,
sign in
to write a code review
Older revisions
ddb33d6a6895
by yendo0206 on Feb 17, 2011
Diff
Miscellaneous modifications.
ae87365312e4
by yendo0206 on Feb 3, 2011
Diff
Code refactoring.
dc4e6839cbbb
by yendo0206 on Feb 1, 2011
Diff
Fixed a bug.
All revisions of this file
File info
Size: 2676 bytes, 65 lines
View raw file
Powered by
Google Project Hosting