java - Async HttpClient 可以将请求发布到 https 吗?
问题描述
我正在使用asyncHttpClient
发布请求,它工作正常。
但是对于其中一个许可证服务器,发布请求总是在失败回调中出现。它给出了错误消息"bad Request"
和status 400
。
这个帖子请求被发送到https
url 不像我发出的其他请求http
。
asyncHttpCLient 可以发布到 https 吗?如果是,那么就 asyncHtppClient 发布请求而言,http post 和 https post 有什么区别。
我对java很陌生,所以可能缺少一些基本步骤。
我正在使用 com.loopj.android:android-async-http:1.4.9
谢谢。
解决方案
简短的回答是肯定的。从图书馆网站上,它说它建立在支持安全(https)连接的apache http 组件上。
首页上的示例代码甚至使用安全 URL 显示它。
导入 com.loopj.android.http.*;
public class TwitterRestClient {
private static final String BASE_URL = "https://api.twitter.com/1/";
private static AsyncHttpClient client = new AsyncHttpClient();
public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.get(getAbsoluteUrl(url), params, responseHandler);
}
public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.post(getAbsoluteUrl(url), params, responseHandler);
}
private static String getAbsoluteUrl(String relativeUrl) {
return BASE_URL + relativeUrl;
}
}
推荐阅读
- python - seaborn:我怎么能告诉它一个分类变量有一个特定的颜色?
- amazon-web-services - Terraform .12 是否可以将标签添加到现有 RDS
- java - JAVA:合并多个属性文件
- python - 如何在 Python 中从 pyqt5 中的 QTableWidget 中删除数据
- c# - (OAuthException - #100) 验证码格式无效
- javascript - javascript中的突变 - 最佳实践
- angular - AWS Cognito 联合登录“构建”环境问题
- python - 如何从稀疏矩阵中过滤非零重要性特征?
- c# - C# - 部分类中的私有静态方法不在文件之间共享?
- macos - 在mac中发生注销时如何以编程方式运行任务