Rocket
Rocket copied to clipboard
Add new media type (application/sep+xml)
Hi Sergio,
I'm loving the rocket so far. I'm trying to create a REST API for a protocol known as IEEE 2030.5. This protocol uses this content type on its header: Content-Type: application/sep+xml
However, when i try to use something like this:
#[post("/dcap/edev/
I get this warning: "'application/sep+xml' is not a known media type"
Is it possible to add this media type to rocket?
Also, the protocol is based on a RESP API + xml + xml schema. Is there any plan to add xml serialize support to rocket?
Finally, the post messages should be anwsered with a HTTP/1.1 204 No Content message. I was able to return a 204 message, but the content lenght is suposed to be 0. However, with rocket i received this: < HTTP/2 204 < server: Rocket < x-frame-options: SAMEORIGIN < x-content-type-options: nosniff < permissions-policy: interest-cohort=() < date: Sun, 20 Jun 2021 02:34:25 GMT
On a commercial REST API server i received this: < HTTP/1.1 204 No Content < Content-Length: 0 < Date: Sun, 20 Jun 2021 02:35:13 GMT
Is it possible to return a Content-Length: 0 HTTP/1.1 204 No Content message?
Thanks in advance, Gustavo Denardin
I get this warning: "'application/sep+xml' is not a known media type" Is it possible to add this media type to rocket?
The warning isn't really in the state we would like (see also #1188). But application/sep+xml
is registered with the IANA, so that seems doable - we would be happy to see a PR for that.
Also, the protocol is based on a RESP API + xml + xml schema. Is there any plan to add xml serialize support to rocket?
Not currently; see https://github.com/SergioBenitez/Rocket/pull/1606#issuecomment-846494295. But, you can implement FromData
or use Data
directly to get the incoming data as bytes, and deserialize it in whatever way best fits your application.
Is it possible to return a Content-Length: 0 HTTP/1.1 204 No Content message?
The missing Content-Length: 0
is probably because of HTTP/2, which encodes the data length in a different way. Do you have a particular reason to need a Content-Length
header even over HTTP/2?
Please see https://github.com/SergioBenitez/Rocket/pull/1714#issuecomment-1491119539. Closing.