documentation: Inconsistent responses when PUTting media
Creating media via HTTP PUT
(docs) sometimes returns a 201
and sometimes returns a 204
. Does anybody know why this is? One practical implication of this is that when Drupal responds with a 201
, a location
header is returned:
{'Date': 'Mon, 06 Apr 2020 15:38:20 GMT', 'Server': 'Apache/2.4.29 (Ubuntu)', 'X-Powered-By': 'PHP/7.2.29-1+ubuntu18.04.1+deb.sury.org+1', 'Cache-Control': 'must-revalidate, no-cache, private', 'Location': 'http://localhost:8000/media/193', 'X-UA-Compatible': 'IE=edge', 'Content-language': 'en', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Expires': 'Sun, 19 Nov 1978 05:00:00 GMT', 'Vary': '', 'X-Generator': 'Drupal 8 (https://www.drupal.org)', 'Content-Length': '0', 'Keep-Alive': 'timeout=5, max=100', 'Connection': 'Keep-Alive', 'Content-Type': 'text/html; charset=UTF-8'}
But when a 204
is returned, there is no location
:
{'Date': 'Mon, 06 Apr 2020 15:38:24 GMT', 'Server': 'Apache/2.4.29 (Ubuntu)', 'X-Powered-By': 'PHP/7.2.29-1+ubuntu18.04.1+deb.sury.org+1', 'Cache-Control': 'must-revalidate, no-cache, private', 'X-UA-Compatible': 'IE=edge', 'Content-language': 'en', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Expires': 'Sun, 19 Nov 1978 05:00:00 GMT', 'Vary': '', 'X-Generator': 'Drupal 8 (https://www.drupal.org)', 'Keep-Alive': 'timeout=5, max=100', 'Connection': 'Keep-Alive'}
In both cases, the media appears to be created.
Some poking around in source code has led me to https://github.com/Islandora/islandora/blob/8.x-1.x/src/Controller/MediaSourceController.php#L143 as the source of this behavior but I am not clear on what triggers success or non-success. In both cases, the media appear to be created.
@dannylamb can you shed some light on this? Or any other @Islandora/8-x-committers ?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 1
- Comments: 32 (32 by maintainers)
Ok, got something, I think: I’ve created about 100 media and didn’t get any
204
s but I did get a500
, so looked in my apache error log. Found these:Strange thing is, they don’t correspond to
500
s I was seeing as a result of my RESTPUT
calls, but they are all being thrown at MediaSourceController.php line 192.I’m not sure if it will matter, I just noticed that it wasn’t being explicitly closed.
I’ll do some logging to see if I can come up with any more information.
Is it reasonable to assume that if the controller generates a 204, the media already has a URL (i.e., a
/media/xxx
URL?@whikloj that is my understanding too but I am seeing this when creating new media.They don’t already exists.