Android HttpHost - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android HttpHost class.

This code example shows how to use the following methods:getHostName, getPort, toHostString
            HttpHost host = (HttpHost) context.getAttribute(key);
            if (host == null) {
                throw new AuthenticationException("Authentication host is not set " + "in the execution context");
            } 
            String authServer;
            if (!this.stripPort && host.getPort() > 0) {
                authServer = host.toHostString();
            } else { 
                authServer = host.getHostName();
            } 
 
            if (LOGGER.isDebugEnabled()) { 
                LOGGER.debug("init " + authServer);
            } 
            final Oid negotiationOid = new Oid(SPNEGO_OID);
 
            final GSSManager manager = GSSManager.getInstance();
            final GSSName serverName = manager.createName("HTTP@" + authServer, GSSName.NT_HOSTBASED_SERVICE);
            final GSSContext gssContext = manager.createContext(serverName.canonicalize(negotiationOid), negotiationOid, null,
                    DEFAULT_LIFETIME);
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            int proxyPort = Proxy.getPort(context);
            if (proxyPort == -1) {
                proxyPort = Proxy.getDefaultPort();
            } 
            if (proxyHost != null && proxyPort > -1) {
                HttpHost proxy = new HttpHost(proxyHost, proxyPort);
                httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
            } else { 
                httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null);
            } 
        } else { 
            httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null);
        } 
    } 
 
    public IgnitedHttpRequest get(String url) {
        return get(url, false);
    } 
 
    public IgnitedHttpRequest get(String url, boolean cached) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getHostName, getPort, getSchemeName
        assertEquals(100, conn.getSocketTimeout());
    } 
 
    @Test 
    public void testHttpCreateEntry() throws Exception { 
        host = new HttpHost("localhost", serverPort, "http");
        conn = connFactory.create(host);
 
        final BasicPoolEntry entry = pool.createEntry(host, conn);
 
        assertEquals(conn, entry.getConnection());
        assertEquals("localhost", entry.getRoute().getHostName());
 
        entry.close();
    } 
 
} 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        try { 
            client = AndroidHttpClient.newInstance("Android");
            HttpUriRequest req = new HttpGet(url);
 
            if (isProxySet) {
                HttpHost proxy = new HttpHost(proxyHost, proxyPort);
                ConnRouteParams.setDefaultProxy(req.getParams(), proxy);
            } 
 
            req.addHeader(
                    "Accept", 
                    "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic"); 
 
            req.addHeader(
                    "x-wap-profile", 
                    "http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-20021212#"); 
 
            HttpResponse response = client.execute(req);
            StatusLine status = response.getStatusLine();
            if (status.getStatusCode() != 200) { // HTTP 200 is success.
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
		if (proxyHost != null && proxyPort != null) {
 
			LOG.debug("Setting proxy '{}:{}'", proxyHost, proxyPort);
 
			proxy = new HttpHost(proxyHost, Integer.parseInt(proxyPort), "http");
 
			setProxy(proxy);
		} 
	} 
 
	public void setProxy(HttpHost proxy) {
		getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
	} 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
    try { 
      Log.w("MmsSender", "Sending MMS1 of length: " + (mms != null ? mms.length : "null"));
      client                 = constructHttpClient(context, parameters);
      URI targetUrl          = new URI(parameters.getMmsc());
      HttpHost target        = new HttpHost(targetUrl.getHost(), targetUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME);
      HttpPost request       = new HttpPost(parameters.getMmsc());
      ByteArrayEntity entity = new ByteArrayEntity(mms);
 
      entity.setContentType("application/vnd.wap.mms-message");
 
      request.setEntity(entity);
      request.setParams(client.getParams());
      request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
//      request.addHeader("x-wap-profile", "http://www.htcmms.com.tw/Android/Common/nexusone/ua-profile.xml"); 
      request.addHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml");
      HttpResponse response = client.execute(target, request);
      StatusLine status     = response.getStatusLine();
 
      if (status.getStatusCode() != 200)
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getHostName
        final String[] subjectAlts) throws SSLException {
        if (this.proxy == null) {
            super.verify(host, cns, subjectAlts, true);
            return; 
        } 
        log.debug("Proxy: {}", proxy);
        if (!host.equals(proxy.getHostName())) {
            super.verify(host, cns, subjectAlts, true);
        } 
    } 
 
    @Override 
    public final String toString() {
        return "LANTERN VERIFIER"; 
    } 
 
} 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            Cursor mCursor = context.getContentResolver().query(uri, null, null, null, null);
            if (mCursor != null && mCursor.moveToFirst()) {
                // 游标移至第一条记录,当然也只有一条 
                String proxyStr = mCursor.getString(mCursor.getColumnIndex("proxy"));
                if (proxyStr != null && proxyStr.trim().length() > 0) {
                    HttpHost proxy = new HttpHost(proxyStr, 80);
                    client.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, proxy);
                } 
                mCursor.close();
            } 
        } 
        return client;
    } 
 
    /** 
     * Upload image into output stream . 
     *  
     * @param out 
     *            : output stream for uploading weibo 
     * @param imgpath 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            String protocol = "http";
 
			if (enableSSL)
                protocol = "https";
 
			params.setParameter(ClientPNames.DEFAULT_HOST, new HttpHost(host,
					port, protocol));
			if (proxy != null) {
				params.setParameter(ConnRoutePNames.DEFAULT_PROXY,
						new HttpHost(proxy, proxyPort, protocol));
			} 
			DefaultHttpClient client = new DefaultHttpClient(
					configureConnectionManager(params), params);
			if (username != null && password != null) {
				client.getCredentialsProvider().setCredentials(
						new AuthScope(host, port, AuthScope.ANY_REALM),
						new UsernamePasswordCredentials(username, password));
				client.addRequestInterceptor(
						new PreemptiveAuthRequestInterceptor(), 0); 
			} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
  public THttpClient(String url, HttpClient client) throws TTransportException {
    try { 
      url_ = new URL(url);
      this.client = client;
      this.host = new HttpHost(url_.getHost(), -1 == url_.getPort() ? url_.getDefaultPort() : url_.getPort(), url_.getProtocol());
    } catch (IOException iox) {
      throw new TTransportException(iox);
    } 
  } 
 
  public void setConnectTimeout(int timeout) {
    connectTimeout_ = timeout;
    if (null != this.client) {
      // WARNING, this modifies the HttpClient params, this might have an impact elsewhere if the 
      // same HttpClient is used for something else. 
      client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectTimeout_);
    } 
  } 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android HttpHost Questions & Answers:

See Code Examples for Android HttpHost Methods: