URLConnection的或了HTTPClient

URLConnection的或了HTTPClient

本文介绍了URLConnection的或了HTTPClient:哪个提供更好的功能和更高的效率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个Android应用程序中创建一个登录表单。我想用POST方法将信息发送到服务器端,其中它是由一个PHP文件处理;这反过来将验证参数和发回响应。

I looking to create a login form for an android application. I want to use a post method to send information to the server side where it is handle by a PHP file; which in turn validates the parameters and sends back a response.

我一直期待通过使用的HttpClient和URLConnection实现,他们都非常similar.Which是在一个Android应用程序?

I've look through implementations using HttpClient and URLConnection, they are very similar.Which is more efficient for utilization within an android app?

谢谢Fabii

推荐答案

我相信,在这种情况下,就看哪​​个API,您觉得更自然。一般情况下,了HTTPClient是一个服务器端应用程序中更有效(或者批量应用程序),因为它允许你指定一个多线程的连接池,以最大数量的总连接,并且每个主机连接计数最大(保证并发连接在同一台主机没有得到序列化(具有HttpURLConnection类的问题))。但是,在一个Android应用程序,你可能只能做一次的单一连接,所以这并不重要。

I believe in this case it's up to whichever API you find more natural. Generally, HTTPClient is more efficient inside a server side application (or maybe batch application), because it allows you to specify a multithreaded connection pool, with a max number of total connections, and a max per host connection count (which ensures concurrent connections to the same host don't get serialized (a problem with HttpUrlConnection)). But in an android app, you'll probably only be making a single connection at a time, so this doesn't matter.

这篇关于URLConnection的或了HTTPClient:哪个提供更好的功能和更高的效率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 05:50