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

Method flush

shell/impala_shell/ImpalaHttpClient.py:353–458  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

351 self.__wbuf.write(buf)
352
353 def flush(self):
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.
397 def sendDataRecvResp(data):
398 # Write payload
399 self.__http.send(data)
400
401 # Get reply to flush the request
402 self.__http_response = self.__http.getresponse()
403 self.code = self.__http_response.status
404 self.message = self.__http_response.reason
405 self.headers = self.__http_response.msg
406 # A '401 Unauthorized' response might mean that we tried cookie-based
407 # authentication with one or more expired cookies.
408 # Delete the cookies and try again.
409 if self.code == 401 and self.areHttpCookiesSaved():
410 self.cleanHttpCookies()

Callers 1

Calls 4

closeMethod · 0.95
readBodyMethod · 0.95
HttpErrorClass · 0.90
decodeMethod · 0.80

Tested by

no test coverage detected