Scribe PATCH request not working

你离开我真会死。 提交于 2019-12-25 01:10:05

问题


Seems like a bug in scribe. It is using java.net.HttpURLConnection which is limited to

/* 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.

Any easy workarounds?


回答1:


For the moment Im removing PATCH from scribe list of available http verbs:

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.




回答2:


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'

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....



来源:https://stackoverflow.com/questions/21119913/scribe-patch-request-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!