Return a tuple (url, data, headers).
(self)
| 3357 | return pairs |
| 3358 | |
| 3359 | def _request_data(self): |
| 3360 | """Return a tuple (url, data, headers).""" |
| 3361 | method = self.method.upper() |
| 3362 | #scheme, netloc, path, parameters, query, frag = _urllib.parse.urlparse(self.action) |
| 3363 | parts = self._urlparse(self.action) |
| 3364 | rest, (query, frag) = parts[:-2], parts[-2:] |
| 3365 | |
| 3366 | if method == "GET": |
| 3367 | self.enctype = "application/x-www-form-urlencoded" # force it |
| 3368 | parts = rest + (urlencode(self._pairs()), None) |
| 3369 | uri = self._urlunparse(parts) |
| 3370 | return uri, None, [] |
| 3371 | elif method == "POST": |
| 3372 | parts = rest + (query, None) |
| 3373 | uri = self._urlunparse(parts) |
| 3374 | if self.enctype == "application/x-www-form-urlencoded": |
| 3375 | return (uri, urlencode(self._pairs()), |
| 3376 | [("Content-Type", self.enctype)]) |
| 3377 | elif self.enctype == "text/plain": |
| 3378 | return (uri, self._pairs(), |
| 3379 | [("Content-Type", self.enctype)]) |
| 3380 | elif self.enctype == "multipart/form-data": |
| 3381 | data = _cStringIO() |
| 3382 | http_hdrs = [] |
| 3383 | mw = MimeWriter(data, http_hdrs) |
| 3384 | f = mw.startmultipartbody("form-data", add_to_http_hdrs=True, |
| 3385 | prefix=0) |
| 3386 | for ii, k, v, control_index in self._pairs_and_controls(): |
| 3387 | self.controls[control_index]._write_mime_data(mw, k, v) |
| 3388 | mw.lastpart() |
| 3389 | return uri, data.getvalue(), http_hdrs |
| 3390 | else: |
| 3391 | raise ValueError( |
| 3392 | "unknown POST form encoding type '%s'" % self.enctype) |
| 3393 | else: |
| 3394 | raise ValueError("Unknown method '%s'" % method) |
| 3395 | |
| 3396 | def _switch_click(self, return_type, request_class=_urllib.request.Request): |
| 3397 | # This is called by HTMLForm and clickable Controls to hide switching |
no test coverage detected