GET 和其他方法是否有默认的媒体类型
Is there a default media type for GET and other methods
在RESTCONF中没有使用任何支持的媒体类型指定查询时是否有任何默认媒体类型?
没有。没有标准的默认值。这是依赖于服务器实现的,所以不要依赖它。
来自 draft-ietf-netconf-restconf-17, Section 5.3,邮件编码:
The server MUST support the "Accept" header field and "406 Not
Acceptable" status-line, as defined in [RFC7231]. The response
output content encoding formats that the client will accept are
identified with the Accept header field in the request. If it is not
specified, the request input encoding format SHOULD be used, or the
server MAY choose any supported content encoding format.
If there was no request input, then the default output encoding is
XML or JSON, depending on server preference. File extensions encoded
in the request are not used to identify format encoding.
并且来自 draft-ietf-netconf-restconf-17, Section 7.1,错误响应消息:
The client SHOULD specify the desired encoding(s) for response
messages by specifying the appropriate media-type(s) in the Accept
header. If the client did not specify an Accept header, then the
same structured syntax name suffix used in the request message SHOULD
be used, or the server MAY choose any supported message encoding
format. If there is no request message the server MUST select
"application/yang-data+xml" or "application/yang-data+json",
depending on server preference.
最终RFC支持草案,正如@predi所说:
在 Message Encoding, Section 5.2:
If there was no request input, then the default output encoding is
XML or JSON, depending on server preference. File extensions encoded
in the request are not used to identify format encoding.
和Error Message Response, Section 7.1
If the client did not specify an "Accept" header, then the same
structured syntax name suffix used in the request message SHOULD be
used, or the server MAY choose any supported message-encoding
format. If there is no request message, the server MUST select
"application/yang-data+xml" or "application/yang-data+json",
depending on server preference.
在RESTCONF中没有使用任何支持的媒体类型指定查询时是否有任何默认媒体类型?
没有。没有标准的默认值。这是依赖于服务器实现的,所以不要依赖它。
来自 draft-ietf-netconf-restconf-17, Section 5.3,邮件编码:
The server MUST support the "Accept" header field and "406 Not Acceptable" status-line, as defined in [RFC7231]. The response output content encoding formats that the client will accept are identified with the Accept header field in the request. If it is not specified, the request input encoding format SHOULD be used, or the server MAY choose any supported content encoding format.
If there was no request input, then the default output encoding is XML or JSON, depending on server preference. File extensions encoded in the request are not used to identify format encoding.
并且来自 draft-ietf-netconf-restconf-17, Section 7.1,错误响应消息:
The client SHOULD specify the desired encoding(s) for response messages by specifying the appropriate media-type(s) in the Accept header. If the client did not specify an Accept header, then the same structured syntax name suffix used in the request message SHOULD be used, or the server MAY choose any supported message encoding format. If there is no request message the server MUST select "application/yang-data+xml" or "application/yang-data+json", depending on server preference.
最终RFC支持草案,正如@predi所说:
在 Message Encoding, Section 5.2:
If there was no request input, then the default output encoding is XML or JSON, depending on server preference. File extensions encoded in the request are not used to identify format encoding.
和Error Message Response, Section 7.1
If the client did not specify an "Accept" header, then the same structured syntax name suffix used in the request message SHOULD be used, or the server MAY choose any supported message-encoding format. If there is no request message, the server MUST select "application/yang-data+xml" or "application/yang-data+json", depending on server preference.