title: Connecting to dropbox via python over a proxy
body: <p>i am trying to connect to a Dropbox Account with python 2.7.4 (x64 win7) and their guide <a href="https://www.dropbox.com/developers/core/authentication#python" rel="nofollow">here</a> helped me a lot. However when i am behind a proxy and this code just won't do it. 
  (From home the code works great, where i am not behind the proxy)</p>
  
  <p>I tried to fiddle with the urllib2 and httplib which are used in the <strong>dropbox/rest.py</strong> but had no luck. I know i have to change the Connection Code but i am not sure how to do this for a Socket.</p>
  
  <p><strong>dropbox/rest.py</strong> [line:99]</p>
  
  <pre><code>def create_connection(address):
      host, port = address
      err = None
      for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
          af, socktype, proto, canonname, sa = res
          sock = None
          try:
              sock = socket.socket(af, socktype, proto)
              sock.connect(sa)
              return sock
  
          except socket.error, _:
              err = _
              if sock is not None:
                  sock.close()
  
      if err is not None:
          raise err
      else:
          raise socket.error("getaddrinfo returns an empty list")
  </code></pre>
  
  <p>i always get the error: [Errno 10060] SocketError.
  I don't really know a lot about networks and ports but i know i can connect to the proxy on port 3128 and dropbox waits on 433. For that matter i had trouble connecting to any <strong>https://</strong>-adress. So i found this code:</p>
  
  <pre><code>proxyHost = 'www.myProxy.adress.com'
  proxyPort = 3128
  conn = httplib.HTTPConnection(proxyHost, proxyPort)
  conn.request("POST", "https://www.google.com")
  </code></pre>
  
  <p>Which works but i lack the skills to adapt this to the socket connection. Especially confusing is that i give the proxyAdress to the connection and have to write the Request in the header or somewhere, compared to the usually way, where i can give the final-Adress to the connection.</p>
  
  <p>This was when i read about <a href="http://sourceforge.net/projects/pysocks/" rel="nofollow">SOCKS</a> for python and tried them but i could not easily replace the socket code with the new "<em>socksocket</em>" for which a proxy can be set with:</p>
  
  <pre><code>import socks
  socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,"www.myProxy.adress.com")
  socket.socket = socks.socksocket
  urllib.urlopen("https://www.google.com/")
  </code></pre>
  
  <p>Any help, how to change the create_connection func of the rest.py to work with a proxy is highly appreciated.</p>