get rid of all urllib2 calls
This commit is contained in:
parent
1f14f6db55
commit
dcc23ba2a4
4 changed files with 11 additions and 17 deletions
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
import cookielib
|
||||
import urllib2
|
||||
from StringIO import StringIO
|
||||
from six import StringIO, PY2
|
||||
from six.moves import urllib
|
||||
from six.moves import http_cookiejar as cookielib
|
||||
|
||||
from celery.utils import get_full_cls_name
|
||||
from celery.backends import default_backend
|
||||
|
|
@ -49,15 +49,15 @@ def api_proxy(request):
|
|||
cj = SessionCookieJar()
|
||||
if 'cj' in request.session:
|
||||
cj.load(request.session['cj'])
|
||||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
|
||||
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
|
||||
opener.addheaders = [
|
||||
('User-Agent', request.META.get('HTTP_USER_AGENT'))
|
||||
]
|
||||
form = ox.MultiPartForm()
|
||||
for key in request.POST:
|
||||
form.add_field(key, request.POST[key])
|
||||
r = urllib2.Request(url)
|
||||
body = str(form)
|
||||
r = urllib.request.Request(url)
|
||||
body = form.body()
|
||||
r.add_header('Content-type', form.get_content_type())
|
||||
r.add_header('Content-length', len(body))
|
||||
r.add_data(body)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue