MCPcopy Create free account
hub / github.com/apache/impala / sendRequestHeaders

Method sendRequestHeaders

shell/impala_shell/ImpalaHttpClient.py:356–393  ·  view source on GitHub ↗
(data_len)

Source from the content-addressed store, hash-verified

354 # Send HTTP request headers. This is repeatable, so if there's a connection error
355 # like when the connection has been closed it's safe to retry.
356 def sendRequestHeaders(data_len):
357 if not self.__reuse_connection and self.isOpen():
358 self.close()
359 if not self.isOpen():
360 self.open()
361
362 # HTTP request
363 if self.using_proxy() and self.scheme == "http":
364 # need full URL of real host for HTTP proxy here (HTTPS uses CONNECT tunnel)
365 self.__http.putrequest('POST', "http://%s:%s%s" %
366 (self.realhost, self.realport, self.path))
367 else:
368 self.__http.putrequest('POST', self.path)
369
370 # Write headers
371 self.__http.putheader('Content-Type', 'application/x-thrift')
372 self.__http.putheader('Content-Length', str(data_len))
373 if data_len > ImpalaHttpClient.MIN_REQUEST_SIZE_FOR_EXPECT:
374 # Add the 'Expect' header to large requests. Note that we do not explicitly wait
375 # for the '100 continue' response before sending the data - HTTPConnection simply
376 # ignores these types of responses, but we'll get the right behavior anyways.
377 self.__http.putheader("Expect", "100-continue")
378 if self.using_proxy() and self.scheme == "http" and self.proxy_auth is not None:
379 self.__http.putheader("Proxy-Authorization", self.proxy_auth)
380
381 self.refreshCustomHeaders()
382 if not self.__custom_headers or 'User-Agent' not in self.__custom_headers:
383 user_agent = 'Python/ImpalaHttpClient'
384 script = os.path.basename(sys.argv[0])
385 if script:
386 user_agent = '%s (%s)' % (user_agent, urllib.parse.quote(script))
387 self.__http.putheader('User-Agent', user_agent)
388
389 if self.__custom_headers:
390 for key, val in six.iteritems(self.__custom_headers):
391 self.__http.putheader(key, val)
392
393 self.__http.endheaders()
394
395 # Complete the request by sending data and getting the response. Return True if the
396 # client should retry this method due to a '401 Unauthorized' response.

Callers

nothing calls this directly

Calls 5

isOpenMethod · 0.95
closeMethod · 0.95
openMethod · 0.95
using_proxyMethod · 0.95
refreshCustomHeadersMethod · 0.95

Tested by

no test coverage detected