Skip to content

Commit 720061a

Browse files
Merge pull request #142 from frennkie/master
enable https scheme
2 parents 4590b23 + e80340f commit 720061a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tika/tika.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,15 @@ def callServer(verb, serverEndpoint, service, data, headers, verbose=Verbose, ti
495495
'''
496496
parsedUrl = urlparse(serverEndpoint)
497497
serverHost = parsedUrl.hostname
498+
scheme = parsedUrl.scheme
499+
498500
port = parsedUrl.port
499501
if classpath is None:
500502
classpath = TikaServerClasspath
501503

502504
global TikaClientOnly
503505
if not TikaClientOnly:
504-
serverEndpoint = checkTikaServer(serverHost, port, tikaServerJar, classpath)
506+
serverEndpoint = checkTikaServer(scheme, serverHost, port, tikaServerJar, classpath)
505507

506508
serviceUrl = serverEndpoint + service
507509
if verb not in httpVerbs:
@@ -515,8 +517,9 @@ def callServer(verb, serverEndpoint, service, data, headers, verbose=Verbose, ti
515517
encodedData = data
516518
if type(data) is unicode_string:
517519
encodedData = data.encode('utf-8')
518-
resp = verbFn(serviceUrl, encodedData, headers=headers)
519-
if verbose:
520+
521+
resp = verbFn(serviceUrl, encodedData, headers=headers, verify=False)
522+
if verbose:
520523
print(sys.stderr, "Request headers: ", headers)
521524
print(sys.stderr, "Response headers: ", resp.headers)
522525
if resp.status_code != 200:
@@ -529,9 +532,10 @@ def callServer(verb, serverEndpoint, service, data, headers, verbose=Verbose, ti
529532
return (resp.status_code, resp.text)
530533

531534

532-
def checkTikaServer(serverHost=ServerHost, port = Port, tikaServerJar=TikaServerJar,classpath=None):
535+
def checkTikaServer(scheme="http", serverHost=ServerHost, port=Port, tikaServerJar=TikaServerJar, classpath=None):
533536
'''
534537
Check that tika-server is running. If not, download JAR file and start it up.
538+
:param scheme: e.g. http or https
535539
:param serverHost:
536540
:param port:
537541
:param tikaServerJar:
@@ -541,7 +545,7 @@ def checkTikaServer(serverHost=ServerHost, port = Port, tikaServerJar=TikaServer
541545
if classpath is None:
542546
classpath = TikaServerClasspath
543547
urlp = urlparse(tikaServerJar)
544-
serverEndpoint = 'http://%s:%s' % (serverHost, port)
548+
serverEndpoint = '%s://%s:%s' % (scheme, serverHost, port)
545549
jarPath = os.path.join(TikaJarPath, 'tika-server.jar')
546550
if 'localhost' in serverEndpoint or '127.0.0.1' in serverEndpoint:
547551
alreadyRunning = checkPortIsOpen(serverHost, port)

0 commit comments

Comments
 (0)