Problem/Motivation
POSTing to ie /entity/node with empty header/content gives or wrong header gives no clue about what was send.
The admin/reports/dblog shows an exception but the REST client is not informed except for a "415 Unsupported Media Type" response
No route found that matches the Content-Type header
How to test
curl --header "Content-Type: WRONG" --data '' http://drupal.d8/entity/node
Proposed resolution
Remaining tasks
User interface changes
API changes
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | include_content_type-2417917-30.patch | 1.82 KB | wim leers |
| #23 | include_content_type-2417917-22.patch | 1.92 KB | sudhanshug |
| #21 | include_content_type-2417917-21.patch | 1.9 KB | sudhanshug |
| #18 | include_content_type-2417917-18.patch | 1.89 KB | sudhanshug |
| #16 | include_content_type-2417917-16.patch | 1.65 KB | sudhanshug |
Comments
Comment #1
clemens.tolboomComment #3
clemens.tolboomAdded String import
Comment #5
clemens.tolboomComment #7
clemens.tolboomDarn .
Comment #9
clemens.tolboomThis is probably partly solved through #2405091: Cannot create user entities - {"error":"Access denied on creating field pass"}
I need to check the other throw.
Comment #10
clemens.tolboomPatch needed a reroll due to https://www.drupal.org/node/2405091.
I still don't get the failure in
What is wrong with the expectedExceptionMessage?
Comment #12
clemens.tolboomI completely missed $format was set to NULL so we need to use the 'raw' CONTENT_TYPE instead.
Comment #13
klausiI think the String class is gone, so we need to use SafeMarkup instead.
Otherwise makes sense to me.
Comment #14
joelpittetFor other exceptions in core we just use sprintf(). Simple but effective;)
Comment #15
clemens.tolboomThis doesn't cover #13
Should we use this?
Comment #16
sudhanshug commentedImplemented
SafeMarkup::format().Comment #18
sudhanshug commentedSorry for the previous patch.
Comment #19
sudhanshug commentedComment #20
zealfire commentedThe latest patch only includes the class of SafeMarkup but does not makes use of it. I think we still need to decide whether we should make use of SafeMarkup or make use of patch submitted in #14.
Comment #21
sudhanshug commentedI think that I uploaded some old patch. Attached is the latest one and implements
SafeMarkup::format().Comment #23
sudhanshug commentedWas able to solve one error but still one more error persists here:
Line 99 of core/tests/Drupal/Tests/Core/Routing/ContentTypeHeaderMatcherTest.phpCan somebody help with that?
Comment #24
sudhanshug commentedComment #26
chx commentedThe %s gets converted to a placeholder. Perhaps you wanted to use sprintf ? Check for example core/lib/Drupal/Core/DependencyInjection/ClassResolver.php .
Comment #27
chx commentedRe #15
We use sprintf.
Comment #28
berdirActually, we use neither these days, just use plain string concatenation.
Comment #29
wim leers#2659070: REST requests without Content-Type header: unhelpful response significantly hinders DX, should receive a 415 response is closely related.
Comment #30
wim leersComment #31
berdirLooks good.
Comment #33
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!