Builds httplib2.Http object Returns: A httplib2.Http object, which is used to make http requests, and which has timeout set by default. To override default timeout call socket.setdefaulttimeout(timeout_in_sec) before interacting with this method.
()
| 1931 | |
| 1932 | |
| 1933 | def build_http(): |
| 1934 | """Builds httplib2.Http object |
| 1935 | |
| 1936 | Returns: |
| 1937 | A httplib2.Http object, which is used to make http requests, and which has timeout set by default. |
| 1938 | To override default timeout call |
| 1939 | |
| 1940 | socket.setdefaulttimeout(timeout_in_sec) |
| 1941 | |
| 1942 | before interacting with this method. |
| 1943 | """ |
| 1944 | if socket.getdefaulttimeout() is not None: |
| 1945 | http_timeout = socket.getdefaulttimeout() |
| 1946 | else: |
| 1947 | http_timeout = DEFAULT_HTTP_TIMEOUT_SEC |
| 1948 | http = httplib2.Http(timeout=http_timeout) |
| 1949 | # 308's are used by several Google APIs (Drive, YouTube) |
| 1950 | # for Resumable Uploads rather than Permanent Redirects. |
| 1951 | # This asks httplib2 to exclude 308s from the status codes |
| 1952 | # it treats as redirects |
| 1953 | try: |
| 1954 | http.redirect_codes = http.redirect_codes - {308} |
| 1955 | except AttributeError: |
| 1956 | # Apache Beam tests depend on this library and cannot |
| 1957 | # currently upgrade their httplib2 version |
| 1958 | # http.redirect_codes does not exist in previous versions |
| 1959 | # of httplib2, so pass |
| 1960 | pass |
| 1961 | |
| 1962 | return http |
no outgoing calls
searching dependent graphs…