Skip to content

Commit

Permalink
Merge pull request #41 from austinhartzheim/develop
Browse files Browse the repository at this point in the history
Added support for SSL to API calls.
  • Loading branch information
metaodi committed May 24, 2015
2 parents d9aa5b5 + 2a3d108 commit 35ecc66
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python:
- '2.7'
- '3.2'
- '3.3'
- '3.4'

before_install:
- sudo apt-get update -qq
Expand Down
13 changes: 9 additions & 4 deletions osmapi/OsmApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
import urllib
from datetime import datetime

from osmapi import __version__

# Python 3.x
if getattr(urllib, 'urlencode', None) is None:
urllib.urlencode = urllib.parse.urlencode

from osmapi import __version__


class UsernamePasswordMissingError(Exception):
"""
Expand Down Expand Up @@ -95,7 +95,7 @@ def __init__(
passwordfile=None,
appid="",
created_by="osmapi/"+__version__,
api="www.openstreetmap.org",
api="https://www.openstreetmap.org",
changesetauto=False,
changesetautotags={},
changesetautosize=500,
Expand Down Expand Up @@ -1773,7 +1773,12 @@ def _http(self, cmd, path, auth, send): # noqa
self._conn = self._get_http_connection()

def _get_http_connection(self):
return httplib.HTTPConnection(self._api, 80)
if self._api.lower().startswith('https://'):
return httplib.HTTPSConnection(self._api[8:], 443)
elif self._api.lower().startswith('http://'):
return httplib.HTTPConnection(self._api[7:], 80)
else:
return httplib.HTTPConnection(self._api, 80)

def _sleep(self):
time.sleep(5)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import codecs
from distutils.core import setup

version = __import__('osmapi').__version__

Expand All @@ -13,7 +14,6 @@
except (IOError, ImportError):
description = 'Python wrapper for the OSM API'

from distutils.core import setup
setup(
name='osmapi',
packages=['osmapi'],
Expand Down

0 comments on commit 35ecc66

Please sign in to comment.