summaryrefslogtreecommitdiffstats
path: root/module/network/HTTPBase.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-12-24 15:36:09 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-12-24 15:36:09 +0100
commit10a476a7c10ac45b6bc2657df24544318c0693f8 (patch)
tree6546aba62984c53a531304d5a5fdff28014ad6fe /module/network/HTTPBase.py
parentpy2.5 fix (diff)
downloadpyload-10a476a7c10ac45b6bc2657df24544318c0693f8.tar.xz
fixed header and POST
Diffstat (limited to 'module/network/HTTPBase.py')
-rw-r--r--module/network/HTTPBase.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/module/network/HTTPBase.py b/module/network/HTTPBase.py
index 3fd8fee49..637d4ad7e 100644
--- a/module/network/HTTPBase.py
+++ b/module/network/HTTPBase.py
@@ -22,7 +22,6 @@ from urllib import urlencode
from urllib2 import Request
from urllib2 import OpenerDirector
-from urllib2 import BaseHandler
from urllib2 import HTTPHandler
from urllib2 import HTTPSHandler
from urllib2 import HTTPDefaultErrorHandler
@@ -31,7 +30,6 @@ from urllib2 import ProxyHandler
from urllib2 import URLError
-from urllib2 import addinfourl
from urllib2 import _parse_proxy
from httplib import HTTPConnection
@@ -187,7 +185,7 @@ class PyLoadHTTPHandler(HTTPHandler):
try:
if req.has_data():
data = req.get_data()
- h.putrequest('POST', req.get_selector())
+ h.putrequest('POST', req.get_selector(), skip_accept_encoding=1)
if not req.headers.has_key('Content-type'):
h.putheader('Content-type',
'application/x-www-form-urlencoded')
@@ -294,6 +292,10 @@ class HTTPBase():
opener.add_handler(ProxyHandler(self.proxies))
opener.version = self.userAgent
opener.addheaders[0] = ("User-Agent", self.userAgent)
+ opener.addheaders.append(("Accept", "*/*"))
+ opener.addheaders.append(("Accept-Language", "en-US,en"))
+ opener.addheaders.append(("Accept-Encoding", "gzip, deflate"))
+ opener.addheaders.append(("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"))
return opener
def createRequest(self, url, get={}, post={}, referer=None, customHeaders={}):
@@ -309,13 +311,13 @@ class HTTPBase():
post = urlencode(post)
req.add_data(post)
- req.add_header("Accept", "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5")
- req.add_header("Accept-Language", "en-US,en")
+ #req.add_header("Accept", "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5")
+ #req.add_header("Accept-Language", "en-US,en")
if referer:
req.add_header("Referer", referer)
- req.add_header("Accept-Encoding", "gzip, deflate")
+ #req.add_header("Accept-Encoding", "gzip, deflate")
for key, val in customHeaders.iteritems():
req.add_header(key, val)
@@ -342,8 +344,9 @@ class HTTPBase():
for key, value in req.headers.iteritems():
print "[HTTP] \t", key, ":", value
print "[HTTP] cookies"
- from pprint import pprint
- pprint(self.cookieJar._cookies)
+ if self.cookieJar:
+ from pprint import pprint
+ pprint(self.cookieJar._cookies)
print "[HTTP] ----"
resp = opener.open(req)
@@ -357,8 +360,9 @@ class HTTPBase():
for key, value in resp.info().dict.iteritems():
print "[HTTP] \t", key, ":", value
print "[HTTP] cookies"
- from pprint import pprint
- pprint(self.cookieJar._cookies)
+ if self.cookieJar:
+ from pprint import pprint
+ pprint(self.cookieJar._cookies)
print "[HTTP] ----"
try:
self.size = int(resp.info()["Content-Length"])