OLD | NEW |
1 # Copyright 2014 Google Inc. All Rights Reserved. | 1 # Copyright 2014 Google Inc. All Rights Reserved. |
2 # | 2 # |
3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
6 # | 6 # |
7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
8 # | 8 # |
9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 # See the License for the specific language governing permissions and | 12 # See the License for the specific language governing permissions and |
13 # limitations under the License. | 13 # limitations under the License. |
14 | 14 |
15 """Classes to encapsulate a single HTTP request. | 15 """Classes to encapsulate a single HTTP request. |
16 | 16 |
17 The classes implement a command pattern, with every | 17 The classes implement a command pattern, with every |
18 object supporting an execute() method that does the | 18 object supporting an execute() method that does the |
19 actuall HTTP request. | 19 actuall HTTP request. |
20 """ | 20 """ |
21 | 21 |
22 __author__ = 'jcgregorio@google.com (Joe Gregorio)' | 22 __author__ = 'jcgregorio@google.com (Joe Gregorio)' |
23 | 23 |
24 import StringIO | 24 import StringIO |
25 import base64 | 25 import base64 |
26 import copy | 26 import copy |
27 import gzip | 27 import gzip |
28 import httplib2 | |
29 import json | 28 import json |
30 import logging | 29 import logging |
31 import mimeparse | 30 import mimeparse |
32 import mimetypes | 31 import mimetypes |
33 import os | 32 import os |
34 import random | 33 import random |
35 import sys | 34 import sys |
36 import time | 35 import time |
37 import urllib | 36 import urllib |
38 import urlparse | 37 import urlparse |
39 import uuid | 38 import uuid |
40 | 39 |
41 from email.generator import Generator | 40 from email.generator import Generator |
42 from email.mime.multipart import MIMEMultipart | 41 from email.mime.multipart import MIMEMultipart |
43 from email.mime.nonmultipart import MIMENonMultipart | 42 from email.mime.nonmultipart import MIMENonMultipart |
44 from email.parser import FeedParser | 43 from email.parser import FeedParser |
45 from errors import BatchError | 44 from errors import BatchError |
46 from errors import HttpError | 45 from errors import HttpError |
47 from errors import InvalidChunkSizeError | 46 from errors import InvalidChunkSizeError |
48 from errors import ResumableUploadError | 47 from errors import ResumableUploadError |
49 from errors import UnexpectedBodyError | 48 from errors import UnexpectedBodyError |
50 from errors import UnexpectedMethodError | 49 from errors import UnexpectedMethodError |
51 from model import JsonModel | 50 from model import JsonModel |
52 from ...oauth2client import util | 51 from third_party import httplib2 |
| 52 from third_party.oauth2client import util |
53 | 53 |
54 | 54 |
55 DEFAULT_CHUNK_SIZE = 512*1024 | 55 DEFAULT_CHUNK_SIZE = 512*1024 |
56 | 56 |
57 MAX_URI_LENGTH = 2048 | 57 MAX_URI_LENGTH = 2048 |
58 | 58 |
59 | 59 |
60 class MediaUploadProgress(object): | 60 class MediaUploadProgress(object): |
61 """Status of a resumable upload.""" | 61 """Status of a resumable upload.""" |
62 | 62 |
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 logging.warning( | 1605 logging.warning( |
1606 'OAuth 1.0 request made with Credentials after tunnel_patch.') | 1606 'OAuth 1.0 request made with Credentials after tunnel_patch.') |
1607 headers['x-http-method-override'] = "PATCH" | 1607 headers['x-http-method-override'] = "PATCH" |
1608 method = 'POST' | 1608 method = 'POST' |
1609 resp, content = request_orig(uri, method, body, headers, | 1609 resp, content = request_orig(uri, method, body, headers, |
1610 redirections, connection_type) | 1610 redirections, connection_type) |
1611 return resp, content | 1611 return resp, content |
1612 | 1612 |
1613 http.request = new_request | 1613 http.request = new_request |
1614 return http | 1614 return http |
OLD | NEW |