-
Bug
-
Resolution: Fixed
-
Neutral
-
2.0
-
None
-
None
-
-
Empty show more show less
-
Declarative REST 11
-
2
We should make sure that if we get an HTTP response code in a response and if our primary goal is knowing what the Status or StatusInfo is, we should be able to display that (https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
Two examples
(Common client config)
baseUrl: 'http://httpbin.org/' class: 'info.magnolia.rest.client.ConfiguredRestClientDefinition' clientFactoryClass: 'info.magnolia.rest.client.factory.DefaultClientFactory' restCalls: requestCode: method: 'GET' entityClass: 'java.lang.String' path: 'status/{code}' defaultValues: code: 404 requestJson: method: 'GET' entityClass: 'com.fasterxml.jackson.databind.JsonNode' path: 'json'
Example: Code 204 - No Content
[#assign code204Call = restfn.call("errors", "requestCode", {"code": 204})] <p> <b>code204Call:</b> ${code204Call.getEntity()?has_content?then(code204Call.getEntity(), code204Call.getStatus())} </p>
Requesting 204 via curl you get "204 NO CONTENT"
martin@ryzen5 ~ $ curl -I http://httpbin.org/status/204? HTTP/1.1 204 NO CONTENT Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: * Content-Type: text/html; charset=utf-8 Date: Fri, 22 Nov 2019 11:48:25 GMT Referrer-Policy: no-referrer-when-downgrade Server: nginx X-Content-Type-Options: nosniff X-Frame-Options: DENY X-XSS-Protection: 1; mode=block Connection: keep-alive
Magnolia displays "200" instead:
Example: Code 205 - Reset Content
[#assign code205Call = restfn.call("errors", "requestCode", {"code": 205})] <p> <b>code205Call:</b> ${code205Call.getEntity()?has_content?then(code205Call.getEntity(), code205Call.getStatus())} </p>
Requesting 205 via curl you get "205 RESET CONTENT"
martin@ryzen5 ~ $ curl -I http://httpbin.org/status/205? HTTP/1.1 205 RESET CONTENT Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: * Content-Length: 0 Content-Type: text/html; charset=utf-8 Date: Fri, 22 Nov 2019 11:48:29 GMT Referrer-Policy: no-referrer-when-downgrade Server: nginx X-Content-Type-Options: nosniff X-Frame-Options: DENY X-XSS-Protection: 1; mode=block Connection: keep-alive
Magnolia doesn't show "205", but instead complains about receiving no entity:
- caused by
-
MGNLRESTCL-98 DOC: Example of handling errors
- Closed
- relates to
-
MGNLRESTCL-43 Handle errors in a REST response
- Closed
- mentioned in
-
Page Loading...