简体   繁体   English

抄写员补丁请求无效

[英]Scribe PATCH request not working

Seems like a bug in scribe. 似乎是抄写员的错误。 It is using java.net.HttpURLConnection which is limited to 它使用的java.net.HttpURLConnection仅限于

/* valid HTTP methods */
private static final String[] methods = {
    "GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"
};

There's no easy way to override this part (to use apache httpClient for instance) and there's a constant in Scribe org.scribe.model.Verb.PATCH, which basically never works with the rest of scribe code as it is now. 没有简单的方法可以覆盖此部分(例如,使用apache httpClient),并且在Scribe org.scribe.model.Verb.PATCH中有一个常量,该常量现在基本上无法与其余的抄写代码一起使用。

Any easy workarounds? 任何简单的解决方法?

For the moment Im removing PATCH from scribe list of available http verbs: 目前,我从可用的HTTP动词的抄写员列表中删除了PATCH

https://github.com/fernandezpablo85/scribe-java/commit/65ae79d2702ccb192161db8fc6d1edaa5df07be8 https://github.com/fernandezpablo85/scribe-java/commit/65ae79d2702ccb192161db8fc6d1edaa5df07be8

On the workaround side, I've found the jersey guys had the same issue and used reflection to get around it. 在解决方法方面,我发现球衣男的遇到相同的问题,并使用反射来解决。

you can use "x-http-method-override" header parameter to over ride HTTP Method please go through below sample code i was using using 'POST' method but overriding it with 'PATCH' 您可以使用“ x-http-method-override”标头参数来覆盖HTTP方法,请仔细阅读以下示例代码,我使用的是“ POST”方法,但使用“ PATCH”覆盖了它

OAuthRequest request = new OAuthRequest(Verb.POST,url);
request.addHeader("x-http-method-override", "PATCH");  
Service.signRequest(konyAccessToken, request);//service is OAuthService instance      
String result = response.getBody();

this work for other HTTP Methods like DELETE,TRACE.... 这项工作适用于其他HTTP方法,例如DELETE,TRACE ....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM