Page MenuHomePhabricator

GWToolset fails if the remote server does not support HTTP HEAD
Closed, DeclinedPublic

Description

A link for example that I have: [[ iiif.nli.org.il/IIIFv21/FL7070748/full/300,/0/default.jpg | image ]]
The function evaluateMediafileUrl tries to request them with HEAD method and fails. So the whole tool fails to upload the images. I do it on the beta server.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

How does it fail? What error do you get?

It's very obvious in the code when/where it does a HEAD request...

		$options = [
			'method' => 'HEAD',
			'followRedirects' => true,
			'userAgent' => Http::userAgent() . ' ' .
				Constants::EXTENSION_NAME . '/' .
				Constants::EXTENSION_VERSION
		];
Reedy renamed this task from GWToolset fails if the links to the media are not supporting HEAD method to GWToolset fails if the remote server does not support HTTP HEAD.Nov 25 2017, 10:57 PM
$ curl -I  iiif.nli.org.il/IIIFv21/FL7070748/full/300,/0/default.jpg
HTTP/1.1 405 Method Not Allowed
Allow: GET
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1053
Date: Sat, 25 Nov 2017 22:58:23 GMT
Server:  

Do we know why that server doesn't support HEAD requests?

It does support it... Just seemingly not for the images

$ curl -i -X OPTIONS iiif.nli.org.il/IIIFv21/FL7070748/full/300,/0/default.jpg
HTTP/1.1 200 OK
Allow: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
Content-Length: 0
Date: Sun, 26 Nov 2017 01:41:19 GMT
Server:  

It seems, 300, in this case, is requesting a dimension. And it's some sort of 404 thumb handler (that maybe doesn't cache?) like we have for Wikipedia et al.... So maybe it's badly written... Or just doesn't know what HEAD is/purposely blocked?

One would suggest someone tells them to tell their server administrator...

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405

The HTTP 405 Method Not Allowed response status code indicates that the request method is known by the server but has been disabled and cannot be used. The two mandatory methods, GET and HEAD, must never be disabled and should not return this error code.

We could make the extension work anyway.. Making the request as a fallback GET, and then stopping when we get content... But eugh