(self, h, req)
| 313 | return r |
| 314 | |
| 315 | def _start_transaction(self, h, req): |
| 316 | try: |
| 317 | if req.data: |
| 318 | data = req.data |
| 319 | if hasattr(req, 'selector'): |
| 320 | h.putrequest(req.get_method() or 'POST', req.selector, skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding")) |
| 321 | else: |
| 322 | h.putrequest(req.get_method() or 'POST', req.get_selector(), skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding")) |
| 323 | if 'Content-type' not in req.headers: |
| 324 | h.putheader('Content-type', |
| 325 | 'application/x-www-form-urlencoded') |
| 326 | if 'Content-length' not in req.headers: |
| 327 | h.putheader('Content-length', '%d' % len(data)) |
| 328 | else: |
| 329 | if hasattr(req, 'selector'): |
| 330 | h.putrequest(req.get_method() or 'GET', req.selector, skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding")) |
| 331 | else: |
| 332 | h.putrequest(req.get_method() or 'GET', req.get_selector(), skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding")) |
| 333 | except (socket.error, _http_client.HTTPException) as err: |
| 334 | raise _urllib.error.URLError(err) |
| 335 | |
| 336 | if 'Connection' not in req.headers: |
| 337 | req.headers['Connection'] = 'keep-alive' |
| 338 | |
| 339 | for args in self.parent.addheaders: |
| 340 | if args[0] not in req.headers: |
| 341 | h.putheader(*args) |
| 342 | for k, v in req.headers.items(): |
| 343 | h.putheader(k, v) |
| 344 | h.endheaders() |
| 345 | if req.data: |
| 346 | h.send(data) |
| 347 | |
| 348 | def _get_connection(self, host): |
| 349 | return NotImplementedError |
no test coverage detected