如何使用HttpURLConnection设置HTTP请求? [英] How to set HTTP request MOVE using HttpURLConnection?
问题描述
如何使用 HttpURLConnection
设置HTTP请求方法MOVE?
How to set HTTP request method MOVE using HttpURLConnection
?
使用 HttpURLConnection
或依赖该类的库,代码抛出异常引起:java.net.ProtocolException:无效的HTTP方法:MOVE
。
所以我猜Java平台不支持 MOVE
方法。
Using HttpURLConnection
or libraries that rely on that class, the code is throwing an exception Caused by: java.net.ProtocolException: Invalid HTTP method: MOVE
.
So I guess the MOVE
method is not supported by the Java platform.
是否有补丁或解决此问题/限制?解决方法可能是另一个用于创建HTTP请求的java库。
Is there a patch or workaround for this issue / limitation? The workaround could be another java library for creating HTTP requests.
编辑:请注意 MOVE $ c WebDav HTTP扩展支持$ c>动词。还有
PATCH
扩展名添加到协议中。
Note that the MOVE
verb is supported WebDav HTTP extension. There is also PATCH
extension that was later added to the protocol.
此处参考的是SkyDrive API,其中包含移动功能。
For reference here is SkyDrive API with the move feature we are trying to implement.
请注意 Ruby平台支持 MOVE
方法一>。 我想知道为什么java不支持甚至不允许这些扩展。
推荐答案
这是HttpURLConnection中的一个错误。如果你不想切换到另一个库,你可以尝试使用内省覆盖该方法(是的,这就是泽西的做法,参见 http://java.net/jira/browse/JERSEY-639 )
It's a bug in HttpURLConnection. If you don't want to switch to a different library, you can try to overwrite the method using introspection (yes, that's what Jersey does, see http://java.net/jira/browse/JERSEY-639)
这篇关于如何使用HttpURLConnection设置HTTP请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!