2015-04-07 102 views
2

使用排球,我POST StringRequest和我得到的错误,当我访问的URL,因为它是排球,BasicNetwork.performRequest:意外的响应码405,同时使StringRequest

https://www.google.com/?gfe_rd=cr&ei=vX8jVdTvOsOq8weigYHICA&gws_rd=cr&fg=1 

但是当使用http而不是https以上,它不会给出错误并且运行良好。

的cookie和客户端的代码如下,

DefaultHttpClient client_R = new DefaultHttpClient(); 
    RequestQueue queue_R = Volley.newRequestQueue(this, new HttpClientStack(client_R)); 
     CookieStore store_R = client_R.getCookieStore(); 
     Cookie cookie_R = new BasicClientCookie("Example_Cookie", "80"); 
     store_R.addCookie(cookie_R); 
下面

是logcat的输出,

[199] BasicNetwork.performRequest: Unexpected response code 405 for https://www.google.com/?gfe_rd=cr&ei=TX4jVcChFaTj8wehzoCgCw&gws_rd=cr&fg=1 

为什么它给错误?由于某些网址有https,因此它正在运行。

回答

0

您是否对您的https请求使用SSL客户端? 您的405错误代码是一个“方法不允许”的错误:see more here

要使用https,我用一个TrustManager的OkHttpClient。

+0

@ Alexis是的,我用过,我已经更新了我的问题。 –

+0

@Alexis Burgos:是否有可能对https请求使用抽象? – jublikon

+0

我几周前用Android Marshmallow得到了这个问题。错误是服务器端(太旧的证书)。 我使用OkHttp在我的应用程序上使用HTTPS(用于订阅密码恢复)。 我只使用2个不同的客户端(1个用于http,1个用于https与SSL工厂)。 –

4

问题是,您正在使用POST API请求GET请求。 在你的StringRequest方法中使用GET而不是POST。

StringRequest sr = new StringRequest(Request.Method.GET, String url, Listener<String> listener, ErrorListener errorListener); 
相关问题