Skip to content

Commit

Permalink
Merge pull request #142 from frennkie/master
Browse files Browse the repository at this point in the history
enable https scheme
  • Loading branch information
chrismattmann authored Jun 18, 2017
2 parents 4590b23 + e80340f commit 720061a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tika/tika.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,15 @@ def callServer(verb, serverEndpoint, service, data, headers, verbose=Verbose, ti
'''
parsedUrl = urlparse(serverEndpoint)
serverHost = parsedUrl.hostname
scheme = parsedUrl.scheme

port = parsedUrl.port
if classpath is None:
classpath = TikaServerClasspath

global TikaClientOnly
if not TikaClientOnly:
serverEndpoint = checkTikaServer(serverHost, port, tikaServerJar, classpath)
serverEndpoint = checkTikaServer(scheme, serverHost, port, tikaServerJar, classpath)

serviceUrl = serverEndpoint + service
if verb not in httpVerbs:
Expand All @@ -515,8 +517,9 @@ def callServer(verb, serverEndpoint, service, data, headers, verbose=Verbose, ti
encodedData = data
if type(data) is unicode_string:
encodedData = data.encode('utf-8')
resp = verbFn(serviceUrl, encodedData, headers=headers)
if verbose:

resp = verbFn(serviceUrl, encodedData, headers=headers, verify=False)
if verbose:
print(sys.stderr, "Request headers: ", headers)
print(sys.stderr, "Response headers: ", resp.headers)
if resp.status_code != 200:
Expand All @@ -529,9 +532,10 @@ def callServer(verb, serverEndpoint, service, data, headers, verbose=Verbose, ti
return (resp.status_code, resp.text)


def checkTikaServer(serverHost=ServerHost, port = Port, tikaServerJar=TikaServerJar,classpath=None):
def checkTikaServer(scheme="http", serverHost=ServerHost, port=Port, tikaServerJar=TikaServerJar, classpath=None):
'''
Check that tika-server is running. If not, download JAR file and start it up.
:param scheme: e.g. http or https
:param serverHost:
:param port:
:param tikaServerJar:
Expand All @@ -541,7 +545,7 @@ def checkTikaServer(serverHost=ServerHost, port = Port, tikaServerJar=TikaServer
if classpath is None:
classpath = TikaServerClasspath
urlp = urlparse(tikaServerJar)
serverEndpoint = 'http://%s:%s' % (serverHost, port)
serverEndpoint = '%s://%s:%s' % (scheme, serverHost, port)
jarPath = os.path.join(TikaJarPath, 'tika-server.jar')
if 'localhost' in serverEndpoint or '127.0.0.1' in serverEndpoint:
alreadyRunning = checkPortIsOpen(serverHost, port)
Expand Down

0 comments on commit 720061a

Please sign in to comment.