1
+ import os
1
2
import pkg_resources
2
3
import ssl
3
4
import sys
@@ -52,6 +53,24 @@ def pinned_session(pool_maxsize=8):
52
53
url_path_quote = urllib .parse .quote
53
54
url_encode = urllib .parse .urlencode
54
55
56
+ DOMAIN = os .environ .get ('DROPBOX_DOMAIN' , '.dropboxapi.com' )
57
+
58
+ # Default short hostname for RPC-style routes.
59
+ HOST_API = 'api'
60
+
61
+ # Default short hostname for upload and download-style routes.
62
+ HOST_CONTENT = 'content'
63
+
64
+ # Default short hostname for longpoll routes.
65
+ HOST_NOTIFY = 'notify'
66
+
67
+ # Default short hostname for the Drobox website.
68
+ HOST_WWW = 'www'
69
+
70
+ API_HOST = os .environ .get ('DROPBOX_API_HOST' , HOST_API + DOMAIN )
71
+ API_CONTENT_HOST = os .environ .get ('DROPBOX_API_CONTENT_HOST' , HOST_CONTENT + DOMAIN )
72
+ API_NOTIFICATION_HOST = os .environ .get ('DROPBOX_API_NOTIFY_HOST' , HOST_NOTIFY + DOMAIN )
73
+ WEB_HOST = os .environ .get ('DROPBOX_WEB_HOST' , HOST_WWW + DOMAIN )
55
74
56
75
class OAuthToken (object ):
57
76
"""
@@ -65,11 +84,6 @@ def __init__(self, key, secret):
65
84
class BaseSession (object ):
66
85
API_VERSION = 1
67
86
68
- API_HOST = "api.dropbox.com"
69
- WEB_HOST = "www.dropbox.com"
70
- API_CONTENT_HOST = "api-content.dropbox.com"
71
- API_NOTIFICATION_HOST = "api-notify.dropbox.com"
72
-
73
87
def __init__ (self , consumer_key , consumer_secret , access_type = "auto" , locale = None , rest_client = rest .RESTClient ):
74
88
"""Initialize a DropboxSession object.
75
89
@@ -151,6 +165,11 @@ def build_url(self, host, target, params=None):
151
165
"""
152
166
return "https://%s%s" % (host , self .build_path (target , params ))
153
167
168
+ BaseSession .API_HOST = API_HOST
169
+ BaseSession .API_CONTENT_HOST = API_CONTENT_HOST
170
+ BaseSession .API_NOTIFICATION_HOST = API_NOTIFICATION_HOST
171
+ BaseSession .WEB_HOST = WEB_HOST
172
+
154
173
class DropboxSession (BaseSession ):
155
174
156
175
def set_token (self , access_token , access_token_secret ):
@@ -251,8 +270,6 @@ def build_access_headers(self, method, resource_url, params=None, request_token=
251
270
"""Build OAuth access headers for a future request.
252
271
253
272
Args:
254
- - ``method``: The HTTP method being used (e.g. 'GET' or 'POST').
255
- - ``resource_url``: The full url the request will be made to.
256
273
- ``params``: A dictionary of parameters to add to what's already on the url.
257
274
Typically, this would consist of POST parameters.
258
275
0 commit comments