Java Code Examples for org.apache.http.HttpHost

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project and-bible, under directory /jsword-tweaks/src/main/java/jsword/org/crosswire/common/util/.

Source file: WebResource.java

  23 
vote

/** 
 * Construct a WebResource for the given URL, going through the optional proxy and port, while timing out if too much time has passed.
 * @param theURI the Resource to get via HTTP
 * @param theProxyHost the proxy host or null
 * @param theProxyPort the proxy port or null, where null means use the standard port
 * @param theTimeout the length of time in milliseconds to allow a connection to respond before timing out
 */
public WebResource(URI theURI,String theProxyHost,Integer theProxyPort,int theTimeout){
  uri=theURI;
  client=new DefaultHttpClient();
  HttpParams params=client.getParams();
  HttpConnectionParams.setSoTimeout(params,theTimeout);
  HttpConnectionParams.setConnectionTimeout(params,theTimeout);
  if (theProxyHost != null && theProxyHost.length() > 0) {
    HttpHost proxy=new HttpHost(theProxyHost,theProxyPort == null ? -1 : theProxyPort.intValue());
    ConnRouteParams.setDefaultProxy(params,proxy);
    ProxySelectorRoutePlanner routePlanner=new ProxySelectorRoutePlanner(client.getConnectionManager().getSchemeRegistry(),ProxySelector.getDefault());
    ((AbstractHttpClient)client).setRoutePlanner(routePlanner);
  }
}
 

Example 2

From project android-rackspacecloud, under directory /extensions/apachehc/src/main/java/org/jclouds/http/apachehc/.

Source file: ApacheHCHttpCommandExecutorService.java

  22 
vote

private org.apache.http.HttpResponse executeRequest(HttpUriRequest nativeRequest) throws IOException, ClientProtocolException {
  URI endpoint=URI.create(nativeRequest.getRequestLine().getUri());
  HttpHost host=new HttpHost(endpoint.getHost(),endpoint.getPort(),endpoint.getScheme());
  org.apache.http.HttpResponse nativeResponse=client.execute(host,nativeRequest);
  return nativeResponse;
}
 

Example 3

From project android-sdk, under directory /src/main/java/com/mobeelizer/mobile/android/.

Source file: MobeelizerRealConnectionManager.java

  22 
vote

private void setProxyIfNecessary(final HttpRequestBase request){
  String proxyHost=Proxy.getHost(application.getContext());
  if (proxyHost == null) {
    return;
  }
  int proxyPort=Proxy.getPort(application.getContext());
  if (proxyPort < 0) {
    return;
  }
  HttpHost proxy=new HttpHost(proxyHost,proxyPort);
  ConnRouteParams.setDefaultProxy(request.getParams(),proxy);
}
 

Example 4

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/synchronisation/tracks/.

Source file: WebClient.java

  22 
vote

private HttpHost GetHost(URI uri){
  HttpHost host;
  int port=uri.getPort();
  if (port == -1) {
    port=uri.getScheme().equalsIgnoreCase("https") ? 443 : 80;
  }
  host=new HttpHost(uri.getHost(),port,uri.getScheme());
  return host;
}
 

Example 5

From project build-info, under directory /build-info-client/src/main/java/org/jfrog/build/client/.

Source file: PreemptiveHttpClient.java

  22 
vote

public void setProxyConfiguration(String host,int port,String username,String password){
  HttpHost proxy=new HttpHost(host,port);
  httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,proxy);
  if (username != null) {
    httpClient.getCredentialsProvider().setCredentials(new AuthScope(host,port),new UsernamePasswordCredentials(username,password));
  }
}
 

Example 6

From project Core_2, under directory /shell/src/main/java/org/jboss/forge/shell/util/.

Source file: PluginUtil.java

  22 
vote

private static void configureProxy(final ProxySettings proxySettings,final DefaultHttpClient client){
  if (proxySettings != null) {
    HttpHost proxy=new HttpHost(proxySettings.getProxyHost(),proxySettings.getProxyPort());
    client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,proxy);
    if (proxySettings.isAuthenticationSupported()) {
      AuthScope authScope=new AuthScope(proxySettings.getProxyHost(),proxySettings.getProxyPort());
      UsernamePasswordCredentials credentials=new UsernamePasswordCredentials(proxySettings.getProxyUserName(),proxySettings.getProxyPassword());
      client.getCredentialsProvider().setCredentials(authScope,credentials);
    }
  }
}
 

Example 7

From project couchdb-lucene, under directory /src/main/java/com/github/rnewson/couchdb/lucene/.

Source file: HttpClientFactory.java

  22 
vote

public void process(final HttpRequest request,final HttpContext context) throws HttpException, IOException {
  final AuthState authState=(AuthState)context.getAttribute(ClientContext.TARGET_AUTH_STATE);
  final CredentialsProvider credsProvider=(CredentialsProvider)context.getAttribute(ClientContext.CREDS_PROVIDER);
  final HttpHost targetHost=(HttpHost)context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
  if (authState.getAuthScheme() == null) {
    AuthScope authScope=new AuthScope(targetHost.getHostName(),targetHost.getPort());
    Credentials creds=credsProvider.getCredentials(authScope);
    if (creds != null) {
      authState.setAuthScheme(new BasicScheme());
      authState.setCredentials(creds);
    }
  }
}
 

Example 8

From project DeliciousDroid, under directory /src/com/deliciousdroid/client/.

Source file: PreemptiveAuthInterceptor.java

  22 
vote

public void process(final HttpRequest request,final HttpContext context) throws HttpException, IOException {
  AuthState authState=(AuthState)context.getAttribute(ClientContext.TARGET_AUTH_STATE);
  CredentialsProvider credsProvider=(CredentialsProvider)context.getAttribute(ClientContext.CREDS_PROVIDER);
  HttpHost targetHost=(HttpHost)context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
  if (authState.getAuthScheme() == null) {
    AuthScope authScope=new AuthScope(targetHost.getHostName(),targetHost.getPort());
    Credentials creds=credsProvider.getCredentials(authScope);
    if (creds != null) {
      authState.setAuthScheme(new BasicScheme());
      authState.setCredentials(creds);
    }
  }
}
 

Example 9

From project droidparts, under directory /extra/src/org/droidparts/http/wrapper/.

Source file: DefaultHttpClientWrapper.java

  22 
vote

@Override protected void setProxy(String protocol,String host,int port,String user,String password){
  HttpHost proxyHost=new HttpHost(host,port,protocol);
  httpClient.getParams().setParameter(DEFAULT_PROXY,proxyHost);
  if (!isEmpty(user) && !isEmpty(password)) {
    AuthScope authScope=new AuthScope(host,port);
    UsernamePasswordCredentials credentials=new UsernamePasswordCredentials(user,password);
    httpClient.getCredentialsProvider().setCredentials(authScope,credentials);
  }
}
 

Example 10

From project EasySOA, under directory /easysoa-proxy/easysoa-proxy-core/easysoa-proxy-core-httpdiscoveryproxy/src/main/java/org/easysoa/proxy/test/.

Source file: HttpUtils.java

  22 
vote

/** 
 * A simple GET Http call to the url
 * @param url
 * @return 
 * @throws ClientProtocolException
 * @throws IOException
 */
public static String doGet(String url) throws ClientProtocolException, IOException {
  ResponseHandler<String> responseHandler=new BasicResponseHandler();
  DefaultHttpClient httpProxyClient=new DefaultHttpClient();
  HttpHost proxy=new HttpHost("localhost",EasySOAConstants.HTTP_DISCOVERY_PROXY_PORT);
  httpProxyClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,proxy);
  return httpProxyClient.execute(new HttpGet(url),responseHandler);
}
 

Example 11

From project eve-api, under directory /cdi/src/main/java/org/onsteroids/eve/api/connector/http/.

Source file: PooledHttpApiConnection.java

  22 
vote

/** 
 * Initializses and configures the http client connection pool.
 */
private void initializeHttpClient(){
  LOG.debug("Configuring the HttpClientPool with a maximum of {} connections",maxConnections);
  HttpParams params=new BasicHttpParams();
  ConnManagerParams.setMaxTotalConnections(params,maxConnections);
  ConnPerRouteBean connPerRoute=new ConnPerRouteBean(maxConnections);
  HttpHost serverHost=new HttpHost(serverUri.getHost(),serverUri.getPort());
  connPerRoute.setMaxForRoute(new HttpRoute(serverHost),maxConnections);
  ConnManagerParams.setMaxConnectionsPerRoute(params,connPerRoute);
  SchemeRegistry schemeRegistry=new SchemeRegistry();
  schemeRegistry.register(new Scheme("http",PlainSocketFactory.getSocketFactory(),80));
  schemeRegistry.register(new Scheme("https",SSLSocketFactory.getSocketFactory(),443));
  ClientConnectionManager cm=new ThreadSafeClientConnManager(params,schemeRegistry);
  httpClient=new DefaultHttpClient(cm,params);
}
 

Example 12

From project exo.social.client, under directory /src/main/java/org/exoplatform/social/client/core/net/.

Source file: SocialHttpClientImpl.java

  22 
vote

@Override public void process(HttpRequest request,HttpContext context) throws HttpException, IOException {
  AuthState authState=(AuthState)context.getAttribute(ClientContext.TARGET_AUTH_STATE);
  CredentialsProvider credsProvider=(CredentialsProvider)context.getAttribute(ClientContext.CREDS_PROVIDER);
  HttpHost targetHost=(HttpHost)context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
  if (authState.getAuthScheme() == null) {
    AuthScope authScope=new AuthScope(targetHost.getHostName(),targetHost.getPort());
    Credentials creds=credsProvider.getCredentials(authScope);
    if (creds != null) {
      authState.setAuthScheme(new BasicScheme());
      authState.setCredentials(creds);
    }
  }
}
 

Example 13

From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/http/.

Source file: HttpClient.java

  22 
vote

@Override public void process(final HttpRequest request,final HttpContext context){
  AuthState authState=(AuthState)context.getAttribute(ClientContext.TARGET_AUTH_STATE);
  CredentialsProvider credsProvider=(CredentialsProvider)context.getAttribute(ClientContext.CREDS_PROVIDER);
  HttpHost targetHost=(HttpHost)context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
  if (authState.getAuthScheme() == null) {
    AuthScope authScope=new AuthScope(targetHost.getHostName(),targetHost.getPort());
    Credentials creds=credsProvider.getCredentials(authScope);
    if (creds != null) {
      authState.setAuthScheme(new BasicScheme());
      authState.setCredentials(creds);
    }
  }
}
 

Example 14

From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.

Source file: TwAjax.java

  22 
vote

private void setHttpClientProxy(DefaultHttpClient httpclient){
  if (myProxyIp == null)   return;
  httpclient.getCredentialsProvider().setCredentials(new AuthScope(myProxyIp,myProxyPort),new UsernamePasswordCredentials(myProxyUsername,myProxyPassword));
  HttpHost proxy=new HttpHost(myProxyIp,myProxyPort);
  httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,proxy);
}
 

Example 15

From project httpbuilder, under directory /src/main/java/groovyx/net/http/.

Source file: AuthConfig.java

  22 
vote

public void process(HttpRequest request,HttpContext ctx) throws HttpException, IOException {
  try {
    HttpHost host=(HttpHost)ctx.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
    final URI requestURI=new URI(host.toURI()).resolve(request.getRequestLine().getUri());
    oauth.signpost.http.HttpRequest oAuthRequest=new OAuthRequestAdapter(request,requestURI);
    this.oauth.sign(oAuthRequest);
  }
 catch (  URISyntaxException ex) {
    throw new HttpException("Error rebuilding request URI",ex);
  }
catch (  OAuthException e) {
    throw new HttpException("OAuth signing error",e);
  }
}
 

Example 16

From project httpClient, under directory /httpclient/src/main/java/org/apache/http/conn/params/.

Source file: ConnRouteParams.java

  22 
vote

/** 
 * Obtains the  {@link ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}parameter value. {@link #NO_HOST} will be mapped to <code>null</code>,to allow unsetting in a hierarchy.
 * @param params    the parameters in which to look up
 * @return  the default proxy set in the argument parameters, or<code>null</code> if not set
 */
public static HttpHost getDefaultProxy(HttpParams params){
  if (params == null) {
    throw new IllegalArgumentException("Parameters must not be null.");
  }
  HttpHost proxy=(HttpHost)params.getParameter(DEFAULT_PROXY);
  if ((proxy != null) && NO_HOST.equals(proxy)) {
    proxy=null;
  }
  return proxy;
}
 

Example 17

From project android-client, under directory /xwiki-android-rest/src/org/xwiki/android/rest/.

Source file: HttpConnector.java

  21 
vote

/** 
 * set user credentials with manually developed preemtive Auth
 */
private void setCredentials(){
  if (isSecured) {
    preemptiveAuth=new HttpRequestInterceptor(){
      public void process(      HttpRequest request,      HttpContext context) throws HttpException, IOException {
        AuthState authState=(AuthState)context.getAttribute(ClientContext.TARGET_AUTH_STATE);
        CredentialsProvider credsProvider=(CredentialsProvider)context.getAttribute(ClientContext.CREDS_PROVIDER);
        HttpHost targetHost=(HttpHost)context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        if (authState.getAuthScheme() == null) {
          AuthScope authScope=new AuthScope(targetHost.getHostName(),targetHost.getPort());
          Credentials creds=credsProvider.getCredentials(authScope);
          if (creds != null) {
            authState.setAuthScheme(new BasicScheme());
            authState.setCredentials(creds);
          }
        }
      }
    }
;
    client.addRequestInterceptor(preemptiveAuth,0);
    Credentials defaultcreds=new UsernamePasswordCredentials(username,password);
    client.getCredentialsProvider().setCredentials(new AuthScope(null,-1,AuthScope.ANY_REALM),defaultcreds);
  }
}
 

Example 18

From project api-sdk-java, under directory /api-sdk/src/main/java/com/smartling/api/sdk/file/.

Source file: FileApiClientAdapterImpl.java

  21 
vote

private void setupProxy(HttpClient httpClient){
  HttpHost proxy;
  String protocol=null;
  if (StringUtils.isNotBlank(System.getProperty(SCHEME_HTTPS + PROPERTY_SUFFIX_PROXY_HOST)) && StringUtils.isNotBlank(System.getProperty(SCHEME_HTTPS + PROPERTY_SUFFIX_PROXY_PORT)))   protocol=SCHEME_HTTPS;
 else   if (StringUtils.isNotBlank(System.getProperty(SCHEME_HTTP + PROPERTY_SUFFIX_PROXY_HOST)) && StringUtils.isNotBlank(System.getProperty(SCHEME_HTTP + PROPERTY_SUFFIX_PROXY_PORT)))   protocol=SCHEME_HTTP;
  if (null != protocol) {
    String proxyHost=System.getProperty(protocol + PROPERTY_SUFFIX_PROXY_HOST);
    Integer proxyPort=Integer.valueOf(System.getProperty(protocol + PROPERTY_SUFFIX_PROXY_PORT));
    String proxyUsername=System.getProperty(protocol + PROPERTY_SUFFIX_PROXY_USERNAME);
    String proxyPassword=System.getProperty(protocol + PROPERTY_SUFFIX_PROXY_PASSWORD);
    if (StringUtils.isNotBlank(proxyUsername) && StringUtils.isNotBlank(proxyPassword) && httpClient instanceof DefaultHttpClient) {
      ((DefaultHttpClient)httpClient).getCredentialsProvider().setCredentials(new AuthScope(proxyHost,proxyPort,protocol),new UsernamePasswordCredentials(proxyUsername,proxyPassword));
    }
    proxy=new HttpHost(proxyHost,proxyPort,protocol);
    httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,proxy);
  }
}
 

Example 19

From project apps-for-android, under directory /Photostream/src/com/google/android/photostream/.

Source file: Flickr.java

  21 
vote

/** 
 * Executes an HTTP request on Flickr's web service. If the response is ok, the content is sent to the specified response handler.
 * @param get The GET request to executed.
 * @param handler The handler which will parse the response.
 * @throws IOException
 */
private void executeRequest(HttpGet get,ResponseHandler handler) throws IOException {
  HttpEntity entity=null;
  HttpHost host=new HttpHost(API_REST_HOST,80,"http");
  try {
    final HttpResponse response=mClient.execute(host,get);
    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
      entity=response.getEntity();
      final InputStream in=entity.getContent();
      handler.handleResponse(in);
    }
  }
  finally {
    if (entity != null) {
      entity.consumeContent();
    }
  }
}
 

Example 20

From project bbb-java, under directory /src/main/java/org/mconf/bbb/api/.

Source file: JoinServiceBase.java

  21 
vote

public int standardJoin(String joinUrl){
  joinedMeeting=new JoinedMeeting();
  try {
    HttpClient client=new DefaultHttpClient();
    HttpGet method=new HttpGet(joinUrl);
    HttpContext context=new BasicHttpContext();
    HttpResponse httpResponse=client.execute(method,context);
    if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK)     log.debug("HTTP GET {} return {}",joinUrl,httpResponse.getStatusLine().getStatusCode());
    HttpUriRequest currentReq=(HttpUriRequest)context.getAttribute(ExecutionContext.HTTP_REQUEST);
    if (!currentReq.getURI().getPath().equals("/client/BigBlueButton.html")) {
      log.error("It was redirected to {} instead of /client/BigBlueButton.html: the server was branded" + " and the HTML name was changed, or it's an error. However, it will continue processing",currentReq.getURI().getPath());
    }
    HttpHost currentHost=(HttpHost)context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
    String enterUrl=currentHost.toURI() + "/bigbluebutton/api/enter";
    String enterResponse=getUrl(client,enterUrl).replace("</response>","<server>" + currentHost.toURI() + "</server></response>");
    joinedMeeting.parse(enterResponse);
  }
 catch (  Exception e) {
    e.printStackTrace();
    log.error("Can't join the url {}",joinUrl);
    return E_SERVER_UNREACHABLE;
  }
  return joinResponse();
}
 

Example 21

From project chargifyService, under directory /src/main/java/com/mondora/chargify/controller/.

Source file: Chargify.java

  21 
vote

protected void setup(String key,String domain){
  this.domain=domain;
  this.key=key;
  host=new HttpHost(domain + ".chargify.com",443,"https");
  UsernamePasswordCredentials creds=new UsernamePasswordCredentials(key,"x");
  credsProvider=new BasicCredentialsProvider();
  credsProvider.setCredentials(new AuthScope(domain + ".chargify.com",443,"ChargifyService API"),creds);
  if (logger.isDebugEnabled())   logger.debug("ChargifyService client created for domain " + domain);
}
 

Example 22

From project CityBikes, under directory /src/net/homelinux/penecoptero/android/citybikes/app/.

Source file: RESTHelper.java

  21 
vote

private static DefaultHttpClient setCredentials(DefaultHttpClient httpclient,String url,String username,String password) throws HttpException, IOException {
  HttpHost targetHost=new HttpHost(url);
  final UsernamePasswordCredentials access=new UsernamePasswordCredentials(username,password);
  httpclient.getCredentialsProvider().setCredentials(new AuthScope(targetHost.getHostName(),targetHost.getPort()),access);
  httpclient.addRequestInterceptor(new HttpRequestInterceptor(){
    @Override public void process(    HttpRequest request,    HttpContext context) throws HttpException, IOException {
      AuthState authState=(AuthState)context.getAttribute(ClientContext.TARGET_AUTH_STATE);
      if (authState.getAuthScheme() == null) {
        authState.setAuthScheme(new BasicScheme());
        authState.setCredentials(access);
      }
    }
  }
,0);
  return httpclient;
}
 

Example 23

From project components-ness-httpclient, under directory /client/src/main/java/com/nesscomputing/httpclient/factory/httpclient4/.

Source file: ApacheHttpClient4Factory.java

  21 
vote

private <T>void contributeVirtualHost(final HttpRequestBase httpRequest,final HttpClientRequest<T> httpClientRequest){
  final String virtualHost=httpClientRequest.getVirtualHost();
  if (StringUtils.isNotBlank(virtualHost)) {
    LOG.debug("Adding Virtual Host: '%s/%d'",virtualHost,httpClientRequest.getVirtualPort());
    httpRequest.getParams().setParameter(ClientPNames.VIRTUAL_HOST,new HttpHost(virtualHost,httpClientRequest.getVirtualPort()));
  }
}
 

Example 24

From project droid-fu, under directory /src/main/java/com/github/droidfu/http/.

Source file: BetterHttp.java

  21 
vote

public static void updateProxySettings(){
  if (appContext == null) {
    return;
  }
  HttpParams httpParams=httpClient.getParams();
  ConnectivityManager connectivity=(ConnectivityManager)appContext.getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo nwInfo=connectivity.getActiveNetworkInfo();
  if (nwInfo == null) {
    return;
  }
  Log.i(LOG_TAG,nwInfo.toString());
  if (nwInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
    String proxyHost=Proxy.getHost(appContext);
    if (proxyHost == null) {
      proxyHost=Proxy.getDefaultHost();
    }
    int proxyPort=Proxy.getPort(appContext);
    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);
  }
}
 

Example 25

From project Fotolia-API, under directory /java/libs/httpcomponents-client-4.1.2/examples/org/apache/http/examples/client/.

Source file: ClientExecuteDirect.java

  21 
vote

public static void main(String[] args) throws Exception {
  DefaultHttpClient httpclient=new DefaultHttpClient();
  try {
    HttpHost target=new HttpHost("www.apache.org",80,"http");
    HttpGet req=new HttpGet("/");
    System.out.println("executing request to " + target);
    HttpResponse rsp=httpclient.execute(target,req);
    HttpEntity entity=rsp.getEntity();
    System.out.println("----------------------------------------");
    System.out.println(rsp.getStatusLine());
    Header[] headers=rsp.getAllHeaders();
    for (int i=0; i < headers.length; i++) {
      System.out.println(headers[i]);
    }
    System.out.println("----------------------------------------");
    if (entity != null) {
      System.out.println(EntityUtils.toString(entity));
    }
  }
  finally {
    httpclient.getConnectionManager().shutdown();
  }
}
 

Example 26

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/provider/.

Source file: BooksStore.java

  20 
vote

/** 
 * Finds the book with the specified id.
 * @param id The id of the book to find (ISBN-10, ISBN-13, etc.)
 * @return A Book instance if the book was found or null otherwise.
 */
public Book findBook(String id){
  final Uri.Builder uri=buildFindBookQuery(id);
  final HttpGet get=new HttpGet(uri.build().toString());
  final Book book=createBook();
  final boolean[] result=new boolean[1];
  try {
    executeRequest(new HttpHost(mHost,80,"http"),get,new ResponseHandler(){
      public void handleResponse(      InputStream in) throws IOException {
        parseResponse(in,new ResponseParser(){
          public void parseResponse(          XmlPullParser parser) throws XmlPullParserException, IOException {
            result[0]=parseBook(parser,book);
          }
        }
);
      }
    }
);
    if (TextUtils.isEmpty(book.mEan) && id.length() == 13) {
      book.mEan=id;
    }
 else     if (TextUtils.isEmpty(book.mIsbn) && id.length() == 10) {
      book.mIsbn=id;
    }
    return result[0] ? book : null;
  }
 catch (  IOException e) {
    android.util.Log.e(LOG_TAG,"Could not find the item with ISBN/EAN: " + id);
  }
  return null;
}
 

Example 27

From project conference-mobile-app, under directory /android-app/tests/src/com/google/android/apps/iosched/io/.

Source file: StubHttpClient.java

  19 
vote

/** 
 * {@inheritDoc} 
 */
@Override protected RequestDirector createClientRequestDirector(final HttpRequestExecutor requestExec,final ClientConnectionManager conman,final ConnectionReuseStrategy reustrat,final ConnectionKeepAliveStrategy kastrat,final HttpRoutePlanner rouplan,final HttpProcessor httpProcessor,final HttpRequestRetryHandler retryHandler,final RedirectHandler redirectHandler,final AuthenticationHandler targetAuthHandler,final AuthenticationHandler proxyAuthHandler,final UserTokenHandler stateHandler,final HttpParams params){
  return new RequestDirector(){
    /** 
 * {@inheritDoc} 
 */
    public HttpResponse execute(    HttpHost target,    HttpRequest request,    HttpContext context) throws HttpException, IOException {
      Log.d(TAG,"Intercepted: " + request.getRequestLine().toString());
      mLastRequest=request;
      return mResponse;
    }
  }
;
}
 

Example 28

From project dccsched, under directory /tests/src/com/google/android/apps/iosched/io/.

Source file: StubHttpClient.java

  19 
vote

/** 
 * {@inheritDoc} 
 */
@Override protected RequestDirector createClientRequestDirector(final HttpRequestExecutor requestExec,final ClientConnectionManager conman,final ConnectionReuseStrategy reustrat,final ConnectionKeepAliveStrategy kastrat,final HttpRoutePlanner rouplan,final HttpProcessor httpProcessor,final HttpRequestRetryHandler retryHandler,final RedirectHandler redirectHandler,final AuthenticationHandler targetAuthHandler,final AuthenticationHandler proxyAuthHandler,final UserTokenHandler stateHandler,final HttpParams params){
  return new RequestDirector(){
    /** 
 * {@inheritDoc} 
 */
    public HttpResponse execute(    HttpHost target,    HttpRequest request,    HttpContext context) throws HttpException, IOException {
      Log.d(TAG,"Intercepted: " + request.getRequestLine().toString());
      mLastRequest=request;
      return mResponse;
    }
  }
;
}
 

Example 29

From project dcnyc10-android, under directory /android/tests.old/src/com/google/android/apps/iosched/io/.

Source file: StubHttpClient.java

  19 
vote

/** 
 * {@inheritDoc} 
 */
@Override protected RequestDirector createClientRequestDirector(final HttpRequestExecutor requestExec,final ClientConnectionManager conman,final ConnectionReuseStrategy reustrat,final ConnectionKeepAliveStrategy kastrat,final HttpRoutePlanner rouplan,final HttpProcessor httpProcessor,final HttpRequestRetryHandler retryHandler,final RedirectHandler redirectHandler,final AuthenticationHandler targetAuthHandler,final AuthenticationHandler proxyAuthHandler,final UserTokenHandler stateHandler,final HttpParams params){
  return new RequestDirector(){
    /** 
 * {@inheritDoc} 
 */
    public HttpResponse execute(    HttpHost target,    HttpRequest request,    HttpContext context) throws HttpException, IOException {
      Log.d(TAG,"Intercepted: " + request.getRequestLine().toString());
      mLastRequest=request;
      return mResponse;
    }
  }
;
}
 

Example 30

From project gddsched2, under directory /trunk/android/tests.old/src/com/google/android/apps/iosched/io/.

Source file: StubHttpClient.java

  19 
vote

/** 
 * {@inheritDoc} 
 */
@Override protected RequestDirector createClientRequestDirector(final HttpRequestExecutor requestExec,final ClientConnectionManager conman,final ConnectionReuseStrategy reustrat,final ConnectionKeepAliveStrategy kastrat,final HttpRoutePlanner rouplan,final HttpProcessor httpProcessor,final HttpRequestRetryHandler retryHandler,final RedirectHandler redirectHandler,final AuthenticationHandler targetAuthHandler,final AuthenticationHandler proxyAuthHandler,final UserTokenHandler stateHandler,final HttpParams params){
  return new RequestDirector(){
    /** 
 * {@inheritDoc} 
 */
    public HttpResponse execute(    HttpHost target,    HttpRequest request,    HttpContext context) throws HttpException, IOException {
      Log.d(TAG,"Intercepted: " + request.getRequestLine().toString());
      mLastRequest=request;
      return mResponse;
    }
  }
;
}