Tag: httpclient

Httpclient 4,错误302.如何redirect?

我想要访问一个首先需要(tomcat服务器)validation的站点,然后使用POST请求login,并让该用户查看该站点的页面。 我使用Httpclient 4.0.1 第一个身份validation正常工作,但不是总是抱怨这个错误的login:“302 Moved Temporarily” 我保持cookies&我保持一个上下文,但什么也没有。 实际上,这个login看起来很有效,因为如果我写了不正确的参数或用户||密码,我就看到了login页面。 所以我猜测什么是不工作的自动redirect。 我的代码,总是抛出IOException,302: DefaultHttpClient httpclient = new DefaultHttpClient(); CookieStore cookieStore = new BasicCookieStore(); httpclient.getParams().setParameter( ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY); HttpContext context = new BasicHttpContext(); context.setAttribute(ClientContext.COOKIE_STORE, cookieStore); //ResponseHandler<String> responseHandler = new BasicResponseHandler(); Credentials testsystemCreds = new UsernamePasswordCredentials(TESTSYSTEM_USER, TESTSYSTEM_PASS); httpclient.getCredentialsProvider().setCredentials( new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), testsystemCreds); HttpPost postRequest = new HttpPost(cms + "/login"); List<NameValuePair> formparams […]

我需要Android中的HttpClient的替代选项来将数据发送到PHP,因为它不再受支持

目前我正在使用HttpClient , HttpPost从Android app发送数据到我的PHP server ,但所有这些方法在API 22中被弃用,并在API 23中删除,所以有什么替代select呢? 我到处search,但没有find任何东西。

我如何使用Pythonlogin到网站?

我该怎么做? 我试图进入一些指定的链接(与urllib),但要做到这一点,我需要login。 我有这个网站的来源: <form id="login-form" action="auth/login" method="post"> <div> <!–label for="rememberme">Remember me</label><input type="checkbox" class="remember" checked="checked" name="remember me" /–> <label for="email" id="email-label" class="no-js">Email</label> <input id="email-email" type="text" name="handle" value="" autocomplete="off" /> <label for="combination" id="combo-label" class="no-js">Combination</label> <input id="password-clear" type="text" value="Combination" autocomplete="off" /> <input id="password-password" type="password" name="password" value="" autocomplete="off" /> <input id="sumbitLogin" class="signin" type="submit" value="Sign In" /> 这可能吗?

如何在Android和/或Java中使用HttpClientpipe理Cookie?

我试图login到一个网站,并维护该会话/ cookie,以便服务器将识别我的login,但我正在努力找出一种方法,从响应中提取cookie并设置为维护我的login请求。 我想知道是否应该采取头“Set-Cookie”或使用CookieStore。 任何帮助是极大的赞赏。 这里是我的代码,有我认为getHeader / getCookie方法会去的注释。 public class Http { DefaultHttpClient client = new DefaultHttpClient(); HttpGet request; HttpEntity entity; HttpResponse response; HttpPost post; CookieStore cookieStore = new BasicCookieStore(); HttpContext localContext = new BasicHttpContext(); public static void setContext() { localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); } public static void getPage(String url) throws Exception { request = new HttpGet(url); response […]

HTTP和HTTPClient在angular度4之间的区别?

我想知道哪个用来构build一个模拟Web服务来testingAngular程序?

DefaultHttpClient到AndroidHttpClient

我的代码有问题,希望得到一些帮助。 我第一次使用这个代码: new DefaultHttpClient().execute(new HttpGet(linkk)).getEntity().writeTo( new FileOutputStream(f)); 它在android 2.3上工作得很好,但在4.0上却不行。 经过一番研究,我听说最好使用AndroidHttpClient,这样它就可以在4.0和3.1上运行。 问题是,我不知道我是否正确修改了我的代码,并没有太多有关AndroidhttpClient在互联网上的例子。 这是我调整的代码: AndroidHttpClient client = AndroidHttpClient.newInstance("Android"); HttpGet request = new HttpGet(linkk); HttpResponse response = client.execute(request); //here is where the exception is thrown response.getEntity().writeTo(new FileOutputStream(f)); 这是logcat显示的内容: 01-03 01:32:11.950: W/dalvikvm(17991): threadid=1: thread exiting with uncaught exception (group=0x40a2e1f8) 01-03 01:32:11.986: E/AndroidRuntime(17991): FATAL EXCEPTION: main 01-03 01:32:11.986: E/AndroidRuntime(17991): java.lang.RuntimeException: […]

如何将Apache HTTP API(legacy)作为编译时间依赖项添加到Android M的build.grade中?

如上所述,Android M将不支持Apache HTTP API。 文档声明: 改用HttpURLConnection类。 要么 要继续使用Apache HTTP API,必须首先在build.gradle文件中声明以下编译时间依赖项: android {useLibrary'org.apache.http.legacy'} 我把我的项目的HttpClient的使用大部分转换为HttpURLConnection,但是,我仍然需要在几个区域使用HttpClient。 因此,我试图声明“org.apache.http.legacy”作为编译时依赖项,但是在build.gradle中得到一个错误: Gradle DSL方法未find:'useLibrary()' 我的问题是:我如何在我的项目中声明“org.apache.http.legacy”作为编译时间依赖项? 任何帮助深表感谢。 谢谢

如何忽略Apache HttpClient 4.0中的SSL证书错误

如何绕过Apache HttpClient 4.0的无效SSL证书错误?

Android弃用apache模块(HttpClient,HttpResponse等)

Android已经弃用了API级别22以来的Apache模块,所以我的问题是,我该如何使用,例如Apache库中的HttpResponse ,而不是Android SDK? 问题是这两个软件包都是一样的。 但是,例如, HttpGet是可以的,因为它在Apache中被称为HttpGetHC4 。

如何使用Apache HttpClient处理无效的SSL证书?

我知道,这个问题有很多不同的问题和答案,但我不明白… 我有:ubuntu-9.10-desktop-amd64 + NetBeans6.7.1从“closures”安装。 代表。 我需要通过HTTPS连接到某个站点。 为此,我使用Apache的HttpClient。 从教程我读: “一旦你正确安装了JSSE,通过SSL的安全HTTP通信应该是 简单的HTTP通信简单。“和一些例子: HttpClient httpclient = new HttpClient(); GetMethod httpget = new GetMethod("https://www.verisign.com/"); try { httpclient.executeMethod(httpget); System.out.println(httpget.getStatusLine()); } finally { httpget.releaseConnection(); } 现在,我写这个: HttpClient client = new HttpClient(); HttpMethod get = new GetMethod("https://mms.nw.ru"); //get.setDoAuthentication(true); try { int status = client.executeMethod(get); System.out.println(status); BufferedInputStream is = new BufferedInputStream(get.getResponseBodyAsStream()); int r=0;byte[] […]