from .packages.urllib3.exceptions import SSLError as _SSLError
from .packages.urllib3.exceptions import HTTPError as _HTTPError
from .packages.urllib3 import connectionpool, poolmanager
+from .packages.urllib3.filepost import encode_multipart_formdata
from .exceptions import (
Timeout, URLRequired, TooManyRedirects, HTTPError, ConnectionError)
from .utils import (
stream_decode_response_unicode, decode_gzip, stream_decode_gzip)
+
+
REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)
body = None
content_type = None
- from .packages.urllib3.filepost import encode_multipart_formdata
-
# Multi-part file uploads.
if self.files:
if not isinstance(self.data, basestring):
# TODO: Conflict?
else:
if self.data:
+
body = self._enc_data
- content_type = 'application/x-www-form-urlencoded'
+ if isinstance(self.data, basestring):
+ content_type = None
+ else:
+ content_type = 'application/x-www-form-urlencoded'
# Add content-type if it wasn't explicitly provided.
if (content_type) and (not 'content-type' in self.headers):
try:
# Send the request.
+
r = conn.urlopen(
method=self.method,
url=url,