使用 HTTPS POST 发送 XML 数据时,如何知道正确的内容类型是什么?
是“application/x-www-form-urlencoded”、“multipart/form-data”、“application/xml”、“text/xml”还是其他?更重要的是,我怎么知道何时使用哪个?
这是一篇非常古老的文章,其中提到使用“multipart/form-data”,而“application/x-www-form-urlencoded”不好。这仍然有效吗? http://skew.org/xml/misc/xml_vs_http/#post
我我并没有真正使用框架 - 我想尽可能地手动编码。
干杯!
Is it "application/x-www-form-urlencoded", "multipart/form-data", "application/xml", "text/xml" or something else? And more importantly, how do I know when to use which?
This is a very old article which says to use "multipart/form-data" and that "application/x-www-form-urlencoded" is bad. Is that still valid advice?
http://skew.org/xml/misc/xml_vs_http/#post
I'm not really using a framework - I want to hand-code this as much as possible.
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于您如何编码数据。您可以使用其中任何一个(在适当的情况下)。
如果您提供 XML 作为消息正文而不对其进行任何其他编码,那么您可能需要 application/xml。
文章有一个示例并提到(还有一些近十年前的示例)如果服务器端处理器不支持它就会出现问题。
如果您正在编写所述处理器,那么您只需确保编写它即可。
It depends how you are encoding the data. You could use any of those (under the right circumstances).
If you are serving up XML as the message body without doing any other encoding on it, then you probably want application/xml.
The article has an example and mentions (with some almost decade old examples) that this is problematic if the server side processor doesn't support it.
If you are writing said processor, then you just have to make sure that you write it so that it does.