vaites / php-apache-tika

Apache Tika bindings for PHP: extract text and metadata from documents, images and other formats
MIT License
116 stars 22 forks source link

https support #32

Closed neerolyte closed 1 year ago

neerolyte commented 1 year ago

Currently trying to make a client with a https server results in an exception e.g:

\Vaites\ApacheTika\Client::make('https://example.com:443/');

results in:

Exception: Unexpected response for /version (400)

/source/vendor/vaites/php-apache-tika/src/Clients/WebClient.php:582
/source/vendor/vaites/php-apache-tika/src/Clients/WebClient.php:496
/source/vendor/vaites/php-apache-tika/src/Clients/WebClient.php:424
/source/vendor/vaites/php-apache-tika/src/Clients/WebClient.php:93
/source/vendor/vaites/php-apache-tika/src/Client.php:126

This is because setUrl() chucks away the scheme at https://github.com/vaites/php-apache-tika/blob/dd145e4e8d4595d3bde883b7b4bd0edecaa4df22/src/Clients/WebClient.php#L108-L124 meaning getUrl() always has to return a hard coded http at https://github.com/vaites/php-apache-tika/blob/dd145e4e8d4595d3bde883b7b4bd0edecaa4df22/src/Clients/WebClient.php#L100-L103 .

I have confirmed just changing the hard coded http to https lets the client work correctly.

vaites commented 1 year ago

You're right. I did not think of that possibility because the Tika server does not support it natively. Fix is on the works...

Out of curiosity, how did you implement SSL, do you use a proxy?

vaites commented 1 year ago

I made a fix with last commit. Can you try using dev-master as version on your composer.json?. If it works, I will publish the changes as a new version...

vaites commented 1 year ago

Fixed on v1.2.5