List of usage examples for org.apache.http.impl.client DefaultHttpClient setRoutePlanner
public synchronized void setRoutePlanner(final HttpRoutePlanner routePlanner)
From source file:org.xwiki.extension.repository.xwiki.internal.resources.ExtensionVersionFileRESTResource.java
private ResponseBuilder downloadLocalExtension(String extensionId, String extensionVersion) throws ResolveException, IOException, QueryException, XWikiException { XWikiDocument extensionDocument = getExistingExtensionDocumentById(extensionId); checkRights(extensionDocument);/*from w w w . j a v a 2s .c o m*/ BaseObject extensionObject = getExtensionObject(extensionDocument); BaseObject extensionVersionObject = getExtensionVersionObject(extensionDocument, extensionVersion); ResponseBuilder response = null; ResourceReference resourceReference = this.repositoryManager.getDownloadReference(extensionDocument, extensionVersionObject); if (ResourceType.ATTACHMENT.equals(resourceReference.getType())) { // It's an attachment AttachmentReference attachmentReference = this.attachmentResolver .resolve(resourceReference.getReference(), extensionDocument.getDocumentReference()); XWikiContext xcontext = getXWikiContext(); XWikiDocument document = xcontext.getWiki().getDocument(attachmentReference.getDocumentReference(), xcontext); checkRights(document); XWikiAttachment xwikiAttachment = document.getAttachment(attachmentReference.getName()); response = getAttachmentResponse(xwikiAttachment); } else if (ResourceType.URL.equals(resourceReference.getType())) { // It's an URL URL url = new URL(resourceReference.getReference()); DefaultHttpClient httpClient = new DefaultHttpClient(); httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "XWikiExtensionRepository"); httpClient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000); httpClient.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000); ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( httpClient.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); httpClient.setRoutePlanner(routePlanner); HttpGet getMethod = new HttpGet(url.toString()); HttpResponse subResponse; try { subResponse = httpClient.execute(getMethod); } catch (Exception e) { throw new IOException("Failed to request [" + getMethod.getURI() + "]", e); } response = Response.status(subResponse.getStatusLine().getStatusCode()); // TODO: find a proper way to do a perfect proxy of the URL without directly using Restlet classes. // Should probably use javax.ws.rs.ext.MessageBodyWriter HttpEntity entity = subResponse.getEntity(); InputRepresentation content = new InputRepresentation(entity.getContent(), new MediaType(entity.getContentType().getValue()), entity.getContentLength()); String type = getValue(extensionObject, XWikiRepositoryModel.PROP_EXTENSION_TYPE); Disposition disposition = new Disposition(Disposition.TYPE_ATTACHMENT); disposition.setFilename(extensionId + '-' + extensionVersion + '.' + type); content.setDisposition(disposition); response.entity(content); } else if (ExtensionResourceReference.TYPE.equals(resourceReference.getType())) { ExtensionResourceReference extensionResource; if (resourceReference instanceof ExtensionResourceReference) { extensionResource = (ExtensionResourceReference) resourceReference; } else { extensionResource = new ExtensionResourceReference(resourceReference.getReference()); } response = downloadRemoteExtension(extensionResource); } else { throw new WebApplicationException(Status.NOT_FOUND); } return response; }
From source file:com.eTilbudsavis.etasdk.network.impl.DefaultHttpNetwork.java
private void setHostNameVerifierAndRoutePlanner(DefaultHttpClient httpClient) { // Use custom HostVerifier to accept our wildcard SSL Certificates: *.etilbudsavis.dk HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory(); socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", socketFactory, 443)); SingleClientConnManager mgr = new SingleClientConnManager(httpClient.getParams(), registry); httpClient = new DefaultHttpClient(mgr, httpClient.getParams()); // Change RoutePlanner to avoid SchemeRegistry causing IllegalStateException. // Some devices with faults in their default route planner httpClient.setRoutePlanner(new DefaultHttpRoutePlanner(registry)); HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier); }
From source file:io.github.tavernaextras.biocatalogue.integration.config.BioCataloguePluginConfigurationPanel.java
/** * Saves recent changes to the configuration parameter map. * Some input validation is performed as well. *///from ww w . j av a 2 s . co m private void applyChanges() { // --- BioCatalogue BASE URL --- String candidateBaseURL = tfBioCatalogueAPIBaseURL.getText(); if (candidateBaseURL.length() == 0) { JOptionPane.showMessageDialog(this, "Service Catalogue base URL must not be blank", "Service Catalogue Configuration", JOptionPane.WARNING_MESSAGE); tfBioCatalogueAPIBaseURL.requestFocusInWindow(); return; } else { try { new URL(candidateBaseURL); } catch (MalformedURLException e) { JOptionPane.showMessageDialog(this, "Currently set Service Catalogue instance URL is not valid\n." + "Please check the URL and try again.", "Service Catalogue Configuration", JOptionPane.WARNING_MESSAGE); tfBioCatalogueAPIBaseURL.selectAll(); tfBioCatalogueAPIBaseURL.requestFocusInWindow(); return; } // check if the base URL has changed from the last saved state if (!candidateBaseURL.equals( configuration.getProperty(BioCataloguePluginConfiguration.SERVICE_CATALOGUE_BASE_URL))) { // Perform various checks on the new URL // Do a GET with "Accept" header set to "application/xml" // We are expecting a 200 OK and an XML doc in return that // contains the BioCataogue version number element. DefaultHttpClient httpClient = new DefaultHttpClient(); // Set the proxy settings, if any if (System.getProperty(PROXY_HOST) != null && !System.getProperty(PROXY_HOST).equals("")) { // Instruct HttpClient to use the standard // JRE proxy selector to obtain proxy information ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( httpClient.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); httpClient.setRoutePlanner(routePlanner); // Do we need to authenticate the user to the proxy? if (System.getProperty(PROXY_USERNAME) != null && !System.getProperty(PROXY_USERNAME).equals("")) { // Add the proxy username and password to the list of credentials httpClient.getCredentialsProvider().setCredentials( new AuthScope(System.getProperty(PROXY_HOST), Integer.parseInt(System.getProperty(PROXY_PORT))), new UsernamePasswordCredentials(System.getProperty(PROXY_USERNAME), System.getProperty(PROXY_PASSWORD))); } } HttpGet httpGet = new HttpGet(candidateBaseURL); httpGet.setHeader("Accept", APPLICATION_XML_MIME_TYPE); // Execute the request HttpContext localContext = new BasicHttpContext(); HttpResponse httpResponse; try { httpResponse = httpClient.execute(httpGet, localContext); } catch (Exception ex1) { logger.error( "Service Catalogue preferences configuration: Failed to do " + httpGet.getRequestLine(), ex1); // Warn the user JOptionPane.showMessageDialog(this, "Failed to connect to the URL of the Service Catalogue instance.\n" + "Please check the URL and try again.", "Service Catalogue Configuration", JOptionPane.INFORMATION_MESSAGE); // Release resource httpClient.getConnectionManager().shutdown(); tfBioCatalogueAPIBaseURL.requestFocusInWindow(); return; } if (httpResponse.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK) { // HTTP/1.1 200 OK HttpEntity httpEntity = httpResponse.getEntity(); String contentType = httpEntity.getContentType().getValue().toLowerCase().trim(); logger.info( "Service Catalogue preferences configuration: Got 200 OK when testing the Service Catalogue instance by doing " + httpResponse.getStatusLine() + ". Content type of response " + contentType); if (contentType.startsWith(APPLICATION_XML_MIME_TYPE)) { String value = null; Document doc = null; try { value = readResponseBodyAsString(httpEntity).trim(); // Try to read this string into an XML document SAXBuilder builder = new SAXBuilder(); byte[] bytes = value.getBytes("UTF-8"); doc = builder.build(new ByteArrayInputStream(bytes)); } catch (Exception ex2) { logger.error( "Service Catalogue preferences configuration: Failed to build an XML document from the response.", ex2); // Warn the user JOptionPane.showMessageDialog(this, "Failed to get the expected response body when testing the Service Catalogue instance.\n" + "The URL is probably wrong. Please check it and try again.", "Service Catalogue Configuration", JOptionPane.INFORMATION_MESSAGE); tfBioCatalogueAPIBaseURL.requestFocusInWindow(); return; } finally { // Release resource httpClient.getConnectionManager().shutdown(); } // Get the version element from the XML document Attribute apiVersionAttribute = doc.getRootElement().getAttribute(API_VERSION); if (apiVersionAttribute != null) { String apiVersion = apiVersionAttribute.getValue(); String versions[] = apiVersion.split("[.]"); String majorVersion = versions[0]; String minorVersion = versions[1]; try { //String patchVersion = versions[2]; // we are not comparing the patch versions String supportedMajorVersion = MIN_SUPPORTED_BIOCATALOGUE_API_VERSION[0]; String supportedMinorVersion = MIN_SUPPORTED_BIOCATALOGUE_API_VERSION[1]; Integer iSupportedMajorVersion = Integer.parseInt(supportedMajorVersion); Integer iMajorVersion = Integer.parseInt(majorVersion); Integer iSupportedMinorVersion = Integer.parseInt(supportedMinorVersion); Integer iMinorVersion = Integer.parseInt(minorVersion); if (!(iSupportedMajorVersion == iMajorVersion && iSupportedMinorVersion <= iMinorVersion)) { // Warn the user JOptionPane.showMessageDialog(this, "The version of the Service Catalogue instance you are trying to connect to is not supported.\n" + "Please change the URL and try again.", "Service Catalogue Configuration", JOptionPane.INFORMATION_MESSAGE); tfBioCatalogueAPIBaseURL.requestFocusInWindow(); return; } } catch (Exception e) { logger.error(e); } } // if null - we'll try to do our best to connect to BioCatalogue anyway } else { logger.error( "Service Catalogue preferences configuration: Failed to get the expected response content type when testing the Service Catalogue instance. " + httpGet.getRequestLine() + " returned content type '" + contentType + "'; expected response content type is 'application/xml'."); // Warn the user JOptionPane.showMessageDialog(this, "Failed to get the expected response content type when testing the Service Catalogue instance.\n" + "The URL is probably wrong. Please check it and try again.", "Service Catalogue Plugin", JOptionPane.INFORMATION_MESSAGE); tfBioCatalogueAPIBaseURL.requestFocusInWindow(); return; } } else { logger.error( "Service Catalogue preferences configuration: Failed to get the expected response status code when testing the Service Catalogue instance. " + httpGet.getRequestLine() + " returned the status code " + httpResponse.getStatusLine().getStatusCode() + "; expected status code is 200 OK."); // Warn the user JOptionPane.showMessageDialog(this, "Failed to get the expected response status code when testing the Service Catalogue instance.\n" + "The URL is probably wrong. Please check it and try again.", "Service Catalogue Configuration", JOptionPane.INFORMATION_MESSAGE); tfBioCatalogueAPIBaseURL.requestFocusInWindow(); return; } // Warn the user of the changes in the BioCatalogue base URL JOptionPane.showMessageDialog(this, "You have updated the Service Catalogue base URL.\n" + "This does not take effect until you restart Taverna.", "Service catalogue Configuration", JOptionPane.INFORMATION_MESSAGE); } // the new base URL seems to be valid - can save it into config // settings configuration.setProperty(BioCataloguePluginConfiguration.SERVICE_CATALOGUE_BASE_URL, candidateBaseURL); /* // also update the base URL in the BioCatalogueClient BioCatalogueClient.getInstance() .setBaseURL(candidateBaseURL);*/ } }
From source file:com.pmi.restlet.ext.httpclient.HttpClientHelper.java
/** * Configures the HTTP client. By default, it try to set the retry handler. * * @param httpClient//from w ww .j a va 2 s .c om * The HTTP client to configure. */ protected void configure(DefaultHttpClient httpClient) { if (getRetryHandler() != null) { try { HttpRequestRetryHandler retryHandler = (HttpRequestRetryHandler) Engine.loadClass(getRetryHandler()) .newInstance(); this.httpClient.setHttpRequestRetryHandler(retryHandler); } catch (Exception e) { getLogger().log(Level.WARNING, "An error occurred during the instantiation of the retry handler.", e); } } ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( httpClient.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); httpClient.setRoutePlanner(routePlanner); }
From source file:net.java.sip.communicator.service.httputil.HttpUtils.java
/** * Returns the preconfigured http client, * using CertificateVerificationService, timeouts, user-agent, * hostname verifier, proxy settings are used from global java settings, * if protected site is hit asks for credentials * using util.swing.AuthenticationWindow. * @param usernamePropertyName the property to use to retrieve/store * username value if protected site is hit, for username * ConfigurationService service is used. * @param passwordPropertyName the property to use to retrieve/store * password value if protected site is hit, for password * CredentialsStorageService service is used. * @param credentialsProvider if not null provider will bre reused * in the new client// w w w . jav a 2s . c o m * @param address the address we will be connecting to */ public static DefaultHttpClient getHttpClient(String usernamePropertyName, String passwordPropertyName, final String address, CredentialsProvider credentialsProvider) throws IOException { HttpParams params = new BasicHttpParams(); params.setParameter(CoreConnectionPNames.SO_TIMEOUT, 10000); params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000); params.setParameter(ClientPNames.MAX_REDIRECTS, MAX_REDIRECTS); DefaultHttpClient httpClient = new DefaultHttpClient(params); HttpProtocolParams.setUserAgent(httpClient.getParams(), System.getProperty("sip-communicator.application.name") + "/" + System.getProperty("sip-communicator.version")); SSLContext sslCtx; try { sslCtx = HttpUtilActivator.getCertificateVerificationService() .getSSLContext(HttpUtilActivator.getCertificateVerificationService().getTrustManager(address)); } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } // note to any reviewer concerned about ALLOW_ALL_HOSTNAME_VERIFIER: // the SSL context obtained from the certificate service takes care of // certificate validation try { Scheme sch = new Scheme("https", 443, new SSLSocketFactoryEx(sslCtx)); httpClient.getConnectionManager().getSchemeRegistry().register(sch); } catch (Throwable t) { logger.error("Error creating ssl socket factory", t); } // set proxy from default jre settings ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( httpClient.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); httpClient.setRoutePlanner(routePlanner); if (credentialsProvider == null) credentialsProvider = new HTTPCredentialsProvider(usernamePropertyName, passwordPropertyName); httpClient.setCredentialsProvider(credentialsProvider); // enable retry connecting with default retry handler // when connecting has prompted for authentication // connection can be disconnected nefore user answers and // we need to retry connection, using the credentials provided httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(3, true)); return httpClient; }
From source file:com.marvelution.hudson.plugins.apiv2.client.connectors.HttpClient4Connector.java
/** * Method to create the {@link HttpClient} * /*from www .j a v a2 s . com*/ * @return the {@link DefaultHttpClient} */ private DefaultHttpClient createClient() { DefaultHttpClient client = new DefaultHttpClient(); if (server.isSecured()) { log.debug("The Server is secured, create the BasicHttpContext to handle preemptive authentication."); client.getCredentialsProvider().setCredentials(getAuthScope(), new UsernamePasswordCredentials(server.getUsername(), server.getPassword())); localContext = new BasicHttpContext(); // Generate BASIC scheme object and stick it to the local execution context BasicScheme basicAuth = new BasicScheme(); localContext.setAttribute("preemptive-auth", basicAuth); // Add as the first request intercepter client.addRequestInterceptor(new PreemptiveAuth(), 0); } if (StringUtils.isNotBlank(System.getProperty("http.proxyHost")) || StringUtils.isNotBlank(System.getProperty("https.proxyHost"))) { log.debug("A System HTTP(S) proxy is set, set the ProxySelectorRoutePlanner for the client"); System.setProperty("java.net.useSystemProxies", "true"); // Set the ProxySelectorRoute Planner to automatically select the system proxy host if set. client.setRoutePlanner(new ProxySelectorRoutePlanner(client.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault())); } return client; }
From source file:net.oddsoftware.android.feedscribe.data.FeedManager.java
void downloadImage(String address, boolean persistant) { if (mDB.hasImage(address)) { mDB.updateImageTime(address, new Date().getTime()); return;//from ww w . ja va 2s . co m } try { // use apache http client lib to set parameters from feedStatus DefaultHttpClient client = new DefaultHttpClient(); // set up proxy handler ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( client.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); client.setRoutePlanner(routePlanner); HttpGet request = new HttpGet(address); request.setHeader("User-Agent", USER_AGENT); HttpResponse response = client.execute(request); StatusLine status = response.getStatusLine(); HttpEntity entity = response.getEntity(); if (entity != null && status.getStatusCode() == 200) { InputStream inputStream = entity.getContent(); // TODO - parse content-length here ByteArrayOutputStream data = new ByteArrayOutputStream(); byte bytes[] = new byte[512]; int count; while ((count = inputStream.read(bytes)) > 0) { data.write(bytes, 0, count); } if (data.size() > 0) { mDB.insertImage(address, new Date().getTime(), persistant, data.toByteArray()); } } } catch (IOException exc) { if (mLog.e()) mLog.e("error downloading image" + address, exc); } }
From source file:net.oddsoftware.android.feedscribe.data.FeedManager.java
void downloadFeedHttp(Feed feed, FeedStatus feedStatus, ArrayList<FeedItem> feedItems, ArrayList<Enclosure> enclosures) { try {/*w w w. ja va 2s . c o m*/ // use apache http client lib to set parameters from feedStatus DefaultHttpClient client = new DefaultHttpClient(); // set up proxy handler ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner( client.getConnectionManager().getSchemeRegistry(), ProxySelector.getDefault()); client.setRoutePlanner(routePlanner); HttpGet request = new HttpGet(feed.mURL); HttpContext httpContext = new BasicHttpContext(); request.setHeader("User-Agent", USER_AGENT); // send etag if we have it if (feedStatus.mETag.length() > 0) { request.setHeader("If-None-Match", feedStatus.mETag); } // send If-Modified-Since if we have it if (feedStatus.mLastModified.getTime() > 0) { SimpleDateFormat dateFormat = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' GMT'", Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); String formattedTime = dateFormat.format(feedStatus.mLastModified); // If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT request.setHeader("If-Modified-Since", formattedTime); } request.setHeader("Accept-Encoding", "gzip,deflate"); HttpResponse response = client.execute(request, httpContext); if (mLog.d()) mLog.d("http request: " + feed.mURL); if (mLog.d()) mLog.d("http response code: " + response.getStatusLine()); InputStream inputStream = null; StatusLine status = response.getStatusLine(); HttpEntity entity = response.getEntity(); if (entity != null) { inputStream = entity.getContent(); } try { if (entity != null && status.getStatusCode() == 200) { Header encodingHeader = entity.getContentEncoding(); if (encodingHeader != null) { if (encodingHeader.getValue().equalsIgnoreCase("gzip")) { inputStream = new GZIPInputStream(inputStream); } else if (encodingHeader.getValue().equalsIgnoreCase("deflate")) { inputStream = new InflaterInputStream(inputStream); } } // remove caching attributes to be replaced with new ones feedStatus.mETag = ""; feedStatus.mLastModified.setTime(0); feedStatus.mTTL = 0; boolean success = parseFeed(inputStream, feed, feedStatus, feedItems, enclosures); if (success) { // if the parse was ok, update these attributes // ETag: "6050003-78e5-4981d775e87c0" Header etagHeader = response.getFirstHeader("ETag"); if (etagHeader != null) { if (etagHeader.getValue().length() < MAX_ETAG_LENGTH) { feedStatus.mETag = etagHeader.getValue(); } else { mLog.e("etag length was too big: " + etagHeader.getValue().length()); } } // Last-Modified: Fri, 24 Dec 2010 00:57:11 GMT Header lastModifiedHeader = response.getFirstHeader("Last-Modified"); if (lastModifiedHeader != null) { try { feedStatus.mLastModified = parseRFC822Date(lastModifiedHeader.getValue()); } catch (ParseException exc) { mLog.e("unable to parse date", exc); } } HttpUriRequest currentReq = (HttpUriRequest) httpContext .getAttribute(ExecutionContext.HTTP_REQUEST); HttpHost currentHost = (HttpHost) httpContext .getAttribute(ExecutionContext.HTTP_TARGET_HOST); String currentUrl = currentHost.toURI() + currentReq.getURI(); mLog.w("loaded redirect from " + request.getURI().toString() + " to " + currentUrl); feedStatus.mLastURL = currentUrl; } } else { if (status.getStatusCode() == 304) { mLog.d("received 304 not modified"); } } } finally { if (inputStream != null) { inputStream.close(); } } } catch (IOException exc) { mLog.e("error downloading feed " + feed.mURL, exc); } }
From source file:gov.nih.nci.nbia.StandaloneDMV3.java
private List<String> connectAndReadFromURL(URL url, List<String> seriesList, String userId, String passWd) { List<String> data = null; DefaultHttpClient httpClient = null; TrustStrategy easyStrategy = new TrustStrategy() { @Override/*w w w . jav a 2s. c o m*/ public boolean isTrusted(X509Certificate[] certificate, String authType) throws CertificateException { return true; } }; try { // SSLContext sslContext = SSLContext.getInstance("SSL"); // set up a TrustManager that trusts everything // sslContext.init(null, new TrustManager[] { new // EasyX509TrustManager(null)}, null); SSLSocketFactory sslsf = new SSLSocketFactory(easyStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); Scheme httpsScheme = new Scheme("https", 443, sslsf); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(httpsScheme); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); ClientConnectionManager ccm = new ThreadSafeClientConnManager(schemeRegistry); HttpParams httpParams = new BasicHttpParams(); // HttpConnectionParams.setConnectionTimeout(httpParams, 50000); // HttpConnectionParams.setSoTimeout(httpParams, new // Integer(12000)); HttpConnectionParams.setConnectionTimeout(httpParams, 500000); HttpConnectionParams.setSoTimeout(httpParams, new Integer(120000)); httpClient = new DefaultHttpClient(ccm, httpParams); httpClient.setRoutePlanner(new ProxySelectorRoutePlanner(schemeRegistry, ProxySelector.getDefault())); // // Additions by lrt for tcia - // // attempt to reduce errors going through a Coyote Point // Equalizer load balance switch // httpClient.getParams().setParameter("http.socket.timeout", new // Integer(12000)); httpClient.getParams().setParameter("http.socket.timeout", new Integer(120000)); httpClient.getParams().setParameter("http.socket.receivebuffer", new Integer(16384)); httpClient.getParams().setParameter("http.tcp.nodelay", true); httpClient.getParams().setParameter("http.connection.stalecheck", false); // // end lrt additions HttpPost httpPostMethod = new HttpPost(url.toString()); List<BasicNameValuePair> postParams = new ArrayList<BasicNameValuePair>(); if (userId != null && passWd != null) { postParams.add(new BasicNameValuePair("userId", userId)); httpPostMethod.addHeader("password", passWd); } postParams.add(new BasicNameValuePair("numberOfSeries", Integer.toString(seriesList.size()))); int i = 0; for (String s : seriesList) { postParams.add(new BasicNameValuePair("series" + Integer.toString(++i), s)); } UrlEncodedFormEntity query = new UrlEncodedFormEntity(postParams); httpPostMethod.setEntity(query); HttpResponse response = httpClient.execute(httpPostMethod); int responseCode = response.getStatusLine().getStatusCode(); if (responseCode != HttpURLConnection.HTTP_OK) { returnStatus = responseCode; return null; } else { InputStream inputStream = response.getEntity().getContent(); data = IOUtils.readLines(inputStream); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (KeyManagementException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (KeyStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnrecoverableKeyException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (httpClient != null) { httpClient.getConnectionManager().shutdown(); } } return data; }