Skip to content
Myr

multipart file uplaods

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent a7d280c · Browse files · 1 file+20 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+20 added−9 removed

  • other:+20 added−9 removed

1 file+20 added−9 removed

modified:requests/models.py+20 added-9 removed
6 unmodified lines
7"""89import urllib10import zlib1111from urlparse import urlparse, urlunparse, urljoin121413from .packages import urllib316# print dir(urllib3)14from .packages.urllib3.filepost import encode_multipart_formdata1516from ._config import get_config17from .structures import CaseInsensitiveDict18from .utils import *
220 unmodified lines
239240 # Build the final URL.241 url = build_url(self.url, self.params)242245 # Setup Files.243 body = None244 content_type = None245246 # Multi-part file uploads.247 if self.files:247 pass248 if not isinstance(self.data, basestring):249 fields = self.data.copy()250 for (k, v) in self.files.items():251 fields.update({k: (None, v.read()))252 (body, content_type) = encode_multipart_formdata(fields)253254 # Setup form data.250 elif self.data:251 pass255 if self.data and (not body):256 if isinstance(self.data, basestring):257 body = self.data258 else:259 body = urlencode(self.data)260 content_type = 'application/x-www-form-urlencoded'261262 # Setup cookies.263 elif self.cookies:264 pass
7 unmodified lines
272273 # Create a pool manager for this one connection.274 pools = PoolManager(275 num_pools=self.config.get('max_connections'),267 maxsize=1)276 maxsize=1,277 timeout=self.timeout278 )279280 # Create a connection.270 connection = pools.connection_from_url(url, timeout=self.timeout)281 connection = pools.connection_from_url(url)282283 # One-off request. Delay fetching the content until needed.284 do_block = False285 else:
181 unmodified lines