List of usage examples for java.net URL getQuery
public String getQuery()
From source file:gov.loc.www.zing.srw.srw_bindings.SRWSoapBindingImpl.java
public Stream searchRetrieveOperation(de.escidoc.core.domain.sru.SearchRetrieveRequestType request, MessageContext msgContext, String handle) throws RemoteException { log.debug("Enter: searchRetrieveOperation"); if (log.isInfoEnabled()) { log.info("request: maximumRecords:" + request.getMaximumRecords() + " query:" + request.getQuery() + " recordPacking:" + request.getRecordPacking() + " recordSchema:" + request.getRecordSchema() + " recordXpath:" + request.getRecordXPath() + " sortKeys:" + request.getSortKeys() + " startRecord:" + request.getStartRecord() + " stylesheet:" + request.getStylesheet() + " version:" + request.getVersion()); }//from w w w. j a va 2 s . c o m long startTime = System.currentTimeMillis(); try { UserContext.setUserContext(handle); try { UserContext.getSecurityContext(); } catch (SystemException e1) { throw new InvocationTargetException(e1); } } catch (Exception ex) { } RestSearchRetrieveResponseType response = null; int resultSetIdleTime = ((Integer) msgContext.getProperty("resultSetIdleTime")).intValue(); NonNegativeInteger nni = request.getResultSetTTL(); if (log.isDebugEnabled()) log.debug("resultSetTTL()=" + nni); if (nni != null) { int ttl = nni.intValue(); log.debug("ttl=" + ttl); if (ttl < resultSetIdleTime) resultSetIdleTime = ttl; } String dbname = (String) msgContext.getProperty("dbname"); SRWDatabase db = (SRWDatabase) msgContext.getProperty("db"); if (log.isDebugEnabled()) log.debug("db=" + db); String sortKeys = request.getSortKeys(); if (sortKeys != null) request.setSortKeys(sortKeys); String query = request.getQuery(); if (query.indexOf('%') >= 0) { try { request.setQuery(java.net.URLDecoder.decode(query, "utf-8")); } catch (java.io.UnsupportedEncodingException e) { } } try { if (query == null) { response = new RestSearchRetrieveResponseType(); response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType()); db.diagnostic(SRWDiagnostic.MandatoryParameterNotSupplied, "query", response.getSearchRetrieveResponse()); } else if (request.getStartRecord() != null && request.getStartRecord().intValue() == Integer.MAX_VALUE) { response = new RestSearchRetrieveResponseType(); response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType()); db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "startRecord", response.getSearchRetrieveResponse()); } else if (request.getMaximumRecords() != null && request.getMaximumRecords().intValue() == Integer.MAX_VALUE) { response = new RestSearchRetrieveResponseType(); response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType()); db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "maximumRecords", response.getSearchRetrieveResponse()); } else if (request.getResultSetTTL() != null && request.getResultSetTTL().intValue() == Integer.MAX_VALUE) { response = new RestSearchRetrieveResponseType(); response.setSearchRetrieveResponse(new de.escidoc.core.domain.sru.SearchRetrieveResponseType()); db.diagnostic(SRWDiagnostic.UnsupportedParameterValue, "resultSetTTL", response.getSearchRetrieveResponse()); } else { try { response = db.doRequest(request); if (response == null) { response = new RestSearchRetrieveResponseType(); response.setSearchRetrieveResponse( new de.escidoc.core.domain.sru.SearchRetrieveResponseType()); response.getSearchRetrieveResponse().setVersion("1.1"); setEchoedSearchRetrieveRequestType(request, response.getSearchRetrieveResponse()); db.diagnostic(SRWDiagnostic.GeneralSystemError, null, response.getSearchRetrieveResponse()); return response.toStream(db, true); } if (msgContext.getProperty("sru") != null && request.getStylesheet() != null) // you can't ask for // a stylesheet in // srw! db.diagnostic(SRWDiagnostic.StylesheetsNotSupported, null, response.getSearchRetrieveResponse()); setEchoedSearchRetrieveRequestType(request, response.getSearchRetrieveResponse()); if (request.getRecordXPath() != null) db.diagnostic(72, null, response.getSearchRetrieveResponse()); if (request.getSortKeys() != null && !request.getSortKeys().equals("") && !db.supportsSort()) db.diagnostic(SRWDiagnostic.SortNotSupported, null, response.getSearchRetrieveResponse()); // set extraResponseData ExtraDataTO extraDataTo = new ExtraDataTO(); // we're going to stick the database name in extraResponseData // every time if (db.databaseTitle != null) extraDataTo.setDatabaseTitle(db.databaseTitle); else extraDataTo.setDatabaseTitle(dbname); // did they ask for the targetURL to be returned? Hashtable extraRequestDataElements = SRWDatabase.parseElements(request.getExtraRequestData()); String s = (String) extraRequestDataElements.get("returnTargetURL"); log.info("returnTargetURL=" + s); if (s != null && !s.equals("false")) { String targetStr = (String) msgContext.getProperty("targetURL"); log.info("targetStr=" + targetStr); if (targetStr != null && targetStr.length() > 0) { URL target = new URL(targetStr); TargetUrlTO targetUrlTo = new TargetUrlTO(); targetUrlTo.setHost(target.getHost()); targetUrlTo.setPort(Integer.toString(target.getPort())); targetUrlTo.setPath(target.getPath()); targetUrlTo.setQuery(Utilities.xmlEncode(target.getQuery())); extraDataTo.setTargetURL(targetUrlTo); } } // set extraResponseData SRWDatabase.setExtraResponseData(response.getSearchRetrieveResponse(), extraDataTo); } catch (Exception e) { log.error(e, e); throw new RemoteException(e.getMessage(), e); } finally { SRWDatabase.putDb(dbname, db); } response.getSearchRetrieveResponse().setVersion("1.1"); log.info("\"" + query + "\"==>" + response.getSearchRetrieveResponse().getNumberOfRecords() + " (" + (System.currentTimeMillis() - startTime) + "ms)"); log.debug("Exit: searchRetrieveOperation"); return response.toStream(db, true); } } catch (Exception e) { throw new RemoteException(e.getMessage(), e); } response.getSearchRetrieveResponse().setVersion("1.1"); log.info("\"" + query + "\"==>" + response.getSearchRetrieveResponse().getNumberOfRecords() + " (" + (System.currentTimeMillis() - startTime) + "ms)"); log.debug("Exit: searchRetrieveOperation"); return response.toStream(db, true); }
From source file:org.apache.axis2.transport.http.AbstractHTTPSender.java
/** * Method used to copy all the common properties * * @param msgContext - The messageContext of the request message * @param url - The target URL * @param httpMethod - The http method used to send the request * @param httpClient - The httpclient used to send the request * @param soapActionString - The soap action atring of the request message * @return MessageFormatter - The messageFormatter for the relavent request message * @throws AxisFault - Thrown in case an exception occurs *//*from w w w .j av a 2 s. co m*/ protected MessageFormatter populateCommonProperties(MessageContext msgContext, URL url, HttpMethodBase httpMethod, HttpClient httpClient, String soapActionString) throws AxisFault { if (isAuthenticationEnabled(msgContext)) { httpMethod.setDoAuthentication(true); } MessageFormatter messageFormatter = MessageProcessorSelector.getMessageFormatter(msgContext); url = messageFormatter.getTargetAddress(msgContext, format, url); httpMethod.setPath(url.getPath()); httpMethod.setQueryString(url.getQuery()); httpMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, messageFormatter.getContentType(msgContext, format, soapActionString)); httpMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost()); if (msgContext.getOptions() != null && msgContext.getOptions().isManageSession()) { // setting the cookie in the out path Object cookieString = msgContext.getProperty(HTTPConstants.COOKIE_STRING); if (cookieString != null) { StringBuffer buffer = new StringBuffer(); buffer.append(cookieString); httpMethod.setRequestHeader(HTTPConstants.HEADER_COOKIE, buffer.toString()); } } if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) { httpClient.getParams().setVersion(HttpVersion.HTTP_1_0); } return messageFormatter; }
From source file:org.codice.alliance.nsili.client.SampleNsiliClient.java
private URI getEncodedUriFromString(String urlString) throws URISyntaxException, MalformedURLException { URL url = new URL(urlString); return new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); }
From source file:org.tomitribe.tribestream.registryng.resources.ClientResource.java
@POST @Path("header/signature") public ComputedHeader getSignature(final HttpSignatureHeader request) { return ofNullable(request) // should be the last one cause can depend on other headers potentially .filter(o -> o.getHeaders() != null && !o.getHeaders().isEmpty() && o.getAlias() != null && o.getSecret() != null) .map(o -> {/*from w w w.ja va2s.c o m*/ final URL url; try { url = new URL(request.getUrl()); } catch (final MalformedURLException e) { throw new IllegalArgumentException(e); } return new ComputedHeader(request.getHeader(), service.httpSign( ofNullable(o.getHeaders()).orElseGet(() -> singletonList("(request-target)")), request.getMethod(), url.getPath() + ofNullable(url.getQuery()).filter(q -> q != null && !q.isEmpty()) .map(q -> "?" + q).orElse(""), o.getAlias(), o.getSecret(), ofNullable(o.getAlgorithm()).orElse("hmac-sha256"), request.getRequestHeaders())); }).orElseThrow(() -> new WebApplicationException(Response.Status.BAD_REQUEST)); }
From source file:org.hyperledger.fabric.sdk.MemberServicesFabricCAImpl.java
/** * MemberServicesFabricCAImpl constructor * * @param url URL for the membership services endpoint * @param pem PEM used for SSL .. not implemented. * @throws CertificateException//from www . j a v a 2 s. com */ public MemberServicesFabricCAImpl(String url, String pem) throws CertificateException, MalformedURLException { this.url = url; URL purl = new URL(url); final String proto = purl.getProtocol(); if (!"http".equals(proto) && !"https".equals(proto)) { throw new IllegalArgumentException( "MemberServicesFabricCAImpl only supports http or https not " + proto); } final String host = purl.getHost(); if (StringUtil.isNullOrEmpty(host)) { throw new IllegalArgumentException("MemberServicesFabricCAImpl url needs host"); } final String path = purl.getPath(); if (!StringUtil.isNullOrEmpty(path)) { throw new IllegalArgumentException( "MemberServicesFabricCAImpl url does not support path portion in url remove path: '" + path + "'."); } final String query = purl.getQuery(); if (!StringUtil.isNullOrEmpty(query)) { throw new IllegalArgumentException( "MemberServicesFabricCAImpl url does not support query portion in url remove query: '" + query + "'."); } /* this.ecaaClient = ECAAGrpc.newBlockingStub(ep.getChannelBuilder().build()); this.ecapClient = ECAPGrpc.newBlockingStub(ep.getChannelBuilder().build()); this.tcapClient = TCAPGrpc.newBlockingStub(ep.getChannelBuilder().build()); this.tlscapClient = TLSCAPGrpc.newBlockingStub(ep.getChannelBuilder().build()); */ this.cryptoPrimitives = new CryptoPrimitives(DEFAULT_HASH_ALGORITHM, DEFAULT_SECURITY_LEVEL); }
From source file:com.tremolosecurity.proxy.filter.PostProcess.java
private void fixRedirect(HttpFilterRequest req, HttpFilterResponse resp, String finalURL, org.apache.http.Header header) { String location = header.getValue(); if (logger.isDebugEnabled()) { logger.debug("Current Location : '" + location + "'"); }/* w w w . ja v a 2s . c om*/ if (location.startsWith("/")) { StringBuffer b = new StringBuffer(); b.append((req.isSecure() ? "https" : "http")).append("://").append(req.getServerName()); if (!(req.getServerPort() == 80 || req.getServerPort() == 443)) { b.append(':').append(req.getServerPort()); } b.append(location); location = b.toString(); if (logger.isDebugEnabled()) { logger.debug("New Location : '" + location + "'"); } resp.addHeader("Location", location); } else { try { URL url = new URL(location); URL target = new URL(finalURL); if (!(url.getProtocol().equalsIgnoreCase(target.getProtocol()) && url.getHost().equalsIgnoreCase(target.getHost()) && (url.getPort() == target.getPort()))) { resp.addHeader("Location", location); } else { StringBuffer b = new StringBuffer(); b.append((req.isSecure() ? "https" : "http")).append("://").append(req.getServerName()); if (!(req.getServerPort() == 80 || req.getServerPort() == 443)) { b.append(':').append(req.getServerPort()); } b.append(url.getPath()); if (url.getQuery() != null) { b.append('?').append(url.getQuery()); } location = b.toString(); if (logger.isDebugEnabled()) { logger.debug("New Location : '" + location + "'"); } resp.addHeader("Location", location); } } catch (MalformedURLException e) { //not a url, so let the browser worry about it resp.addHeader("Location", location); } } }
From source file:com.concentricsky.android.khanacademy.app.ShowProfileActivity.java
/** * Get the current user, and fail if there is none. *//*w ww .ja v a 2 s . c om*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); destroyed = false; this.webViewTimeoutPromptDialog = new AlertDialog.Builder(this) .setMessage("The page is taking a long time to respond. Stop loading?") .setPositiveButton("Stop", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (webView != null) { webView.stopLoading(); finish(); } } }).setNegativeButton("Wait", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { stopWebViewLoadTimeout(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { startWebViewLoadTimeout(); } }).create(); getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.profile); setTitle(getString(R.string.profile_title)); webView = (WebView) findViewById(R.id.web_view); webView.setMinimumWidth(800); enableJavascript(webView); webView.getSettings().setDefaultZoom(ZoomDensity.FAR); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView webView, String url) { Log.d(LOG_TAG, "shouldOverrideUrlLoading: " + url); URL parsed = null; try { parsed = new URL(url); } catch (MalformedURLException e) { // Let the webview figure that one out. return false; } // Only ka links will load in this webview. if (parsed.getHost().equals("www.khanacademy.org")) { // Video urls should link into video detail. See below for another video url format. if (parsed.getPath().equals("/video")) { String query = parsed.getQuery(); if (query != null && query.length() > 0) { String[] items = query.split("&"); String videoId = null; for (String item : items) { String[] parts = item.split("=", 2); if (parts.length > 1) { if ("v".equals(parts[0])) { videoId = parts[1]; break; } } } if (videoId != null) { String[] ids = normalizeVideoAndTopicId(videoId, ""); if (ids != null) { launchVideoDetailActivity(ids[0], ids[1]); return true; } } } // There was no ?v= or something weird is going on. Allow the page // load, which should hit KA's nice "no video found" page. showSpinner(); startWebViewLoadTimeout(); return false; } if (parsed.getPath().startsWith("/profile")) { // navigation within the profile makes sense here. showSpinner(); startWebViewLoadTimeout(); return false; } // Embedded logout option (in upper left menu) can be intercepted and cause the app to be logged out as well. if (parsed.getPath().equals("/logout")) { if (dataService != null) { dataService.getAPIAdapter().logout(); } finish(); return false; // try to let the webview hit logout to get the cookies cleared as we exit } // There is a new kind of video url now.. thanks guys.. // http://www.khanacademy.org/video/subtraction-2 // redirects to // http://www.khanacademy.org/math/arithmetic/addition-subtraction/two_dig_add_sub/v/subtraction-2 String[] path = parsed.getPath().split("/"); List<String> parts = Arrays.asList(path); if (parts.contains("v")) { String videoId = null; String topicId = null; for (int i = path.length - 1; i >= 0; --i) { if (path[i].equals("v")) { continue; } if (videoId == null) { videoId = path[i]; } else if (topicId == null) { topicId = path[i]; } else { break; } } if (videoId != null && topicId != null && dataService != null) { // Looks like a video url. Double check that we have the topic and video before launching detail activity. Log.d(LOG_TAG, "video and topic ids found; looks like a video url."); String[] ids = normalizeVideoAndTopicId(videoId, topicId); if (ids != null) { launchVideoDetailActivity(ids[0], ids[1]); return true; } } } else if (parsed.getPath().startsWith("/video")) { String videoId = path[path.length - 1]; String[] ids = normalizeVideoAndTopicId(videoId, ""); if (ids != null) { launchVideoDetailActivity(ids[0], ids[1]); return true; } } // showSpinner(); // startWebViewLoadTimeout(); // return false; } // All other urls should launch in the browser instead of here, except hash changes if we can distinguish. loadInBrowser(url); return true; } @Override public void onPageFinished(WebView view, String url) { Log.d(LOG_TAG, "onPageFinished"); stopWebViewLoadTimeout(); if (!destroyed) { hideSpinner(); } } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { Log.d(LOG_TAG, "onPageStarted"); stopWebViewLoadTimeout(); // view.loadUrl("javascript:document.addEventListener( 'DOMContentLoaded',function() {AndroidApplication.jqueryReady()} );"); // handler.postDelayed(new Runnable() { // @Override // public void run() { // if (!destroyed) { // hijack(); // } // } // }, 100); } }); // webView.addJavascriptInterface(new Object() { // public void log(String msg) { // Log.d(LOG_TAG, "JSLOG: " + msg); // } // public void jqueryReady() { // Log.d(LOG_TAG, "javascript: jqueryReady"); // hijack(); // } // }, "AndroidApplication"); // showSpinner(); requestDataService(new ObjectCallback<KADataService>() { @Override public void call(KADataService service) { dataService = service; api = service.getAPIAdapter(); String[] credentials = getCurrentLoginCredentials(); loginUser(credentials[0], credentials[1]); } }); }
From source file:org.urbanstew.soundcloudapi.SoundCloudAPI.java
/** * Completes the OAuth 1.0a authorization steps with SoundCloud, assuming the consumer application * can use a local port to receive the verification code. * //from w w w .ja v a 2s . c o m * <p>The function acts as a minimal HTTP server and will listen on the port specified in the * <code>url</code> (or the default HTTP port, if no port is specified in the <code>url</code>). It will provide the * specified <code>response</code> when it receives a request for the path specified in the <code>url</code>, and * assuming the request includes the verification code, terminate successfully. * To all other requests it will respond with a <code>Not Found</code> error, and continue listening. * * <p>The following example assumes the consumer application is running on the client's computer / device. * Hence, it uses a local URL ("http://localhost:8088/") to receive the verification code callback. The function * will listen on specified port 8088 to receive the callback.</p> * * <pre> * {@code * soundcloudapi.authorizeUsingUrl * ( * "http://localhost:8088/", * "Thank you for authorizing", * new AuthorizationURLOpener() * { * public void openAuthorizationURL(String authorizationURL) * { * System.out.println("Please visit " + authorizationURL); * } * } * ); * } * </pre> * * @param url - a callback URL via which the user can provide the verification code. * @param response - a response given back to the user when they allow access and get redirected to the callback URL. * @param URLOpener - an AuthorizationURLOpener which can open the authorization URL to the user when needed. * * @return true if the process is completed successfully, false if the process was canceled via <code>cancelAuthorizeUsingUrl</code>. * * @throws OAuthCommunicationException * @throws OAuthExpectationFailedException * @throws OAuthNotAuthorizedException * @throws OAuthMessageSignerException * @throws IOException * @since 0.9.1 * @see #cancelAuthorizeUsingUrl() */ public boolean authorizeUsingUrl(final String url, final String response, final AuthorizationURLOpener URLOpener) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException, IOException { mCancelAuthorization = false; unauthorize(); URLOpener.openAuthorizationURL(obtainRequestToken(url)); URL parsedUrl = new URL(url); int port = parsedUrl.getPort(); if (port == -1) port = parsedUrl.getDefaultPort(); ServerSocket server = null; String verificationCode = null; try { server = new ServerSocket(port); server.setSoTimeout(500); while (verificationCode == null) { Socket socket = null; BufferedReader in = null; PrintWriter out = null; try { try { socket = server.accept(); } catch (java.io.InterruptedIOException e) { if (mCancelAuthorization) { unauthorize(); return false; } else continue; } in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String requestedUrl = in.readLine().split("\\s+")[1]; URL parsedRequestedUrl = new URL("http://localhost" + requestedUrl); out = new PrintWriter(socket.getOutputStream(), true); if (!parsedRequestedUrl.getPath().equals(parsedUrl.getPath())) out.print("HTTP/1.1 404 Not Found"); else { out.print("HTTP/1.1 200 OK\n\n" + response); for (String parameter : parsedRequestedUrl.getQuery().split("&")) { String[] keyValue = parameter.split("="); if (keyValue[0].equals("oauth_verifier")) verificationCode = keyValue[1]; } if (verificationCode == null) // problem - why didn't we get a verification code? verificationCode = ""; } out.flush(); } finally { closeQuietly(in); closeQuietly(out); closeQuietly(socket); } } } finally { closeQuietly(server); } if (verificationCode.length() > 0) { obtainAccessToken(verificationCode); return true; } else return false; }
From source file:org.jahia.modules.filter.WebClippingFilter.java
private String getURLContentWithGetMethod(String urlToClip, RenderContext renderContext, Resource resource, RenderChain chain, Map map) throws IOException { String path = urlToClip;// ww w . j ava 2 s .co m Map parameters = (Map) map.get("URL_PARAMS"); // Get the httpClient HttpClient httpClient = new HttpClient(); Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 443)); httpClient.getParams().setContentCharset("UTF-8"); // // Add parameters if (parameters != null) { StringBuffer params = new StringBuffer(4096); Iterator iterator = parameters.entrySet().iterator(); int index = 0; String characterEncoding = httpClient.getParams().getContentCharset(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); if (!entry.getKey().toString().equals("original_method") && !entry.getKey().toString().equals("jahia_url_web_clipping")) { // Is not a jahia params so pass it to the url if (!parameters.isEmpty()) { final Object value = entry.getValue(); if (value instanceof String[]) { String[] strings = (String[]) value; StringBuffer buffer = new StringBuffer(4096); for (int i = 0; i < strings.length; i++) { String string = strings[i]; buffer.append((i != 0) ? "," : "").append(string); } params.append(index == 0 ? "?" : "&").append(entry.getKey().toString()).append("=") .append(URLEncoder.encode(buffer.toString(), characterEncoding)); index++; } else { params.append(index == 0 ? "?" : "&").append(entry.getKey().toString()).append("=") .append(URLEncoder.encode(value.toString(), characterEncoding)); index++; } } } } path = path + params.toString(); } // Rebuild Path by encoding the path URL targetURL = new URL(path); String[] pathInfo = targetURL.getPath().split("/"); StringBuffer pathBuffer; if (pathInfo.length > 0) { pathBuffer = new StringBuffer(URLEncoder.encode(pathInfo[0], "UTF-8")); for (int i = 1; i < pathInfo.length; i++) { String s = pathInfo[i]; String[] s2 = s.split(";"); pathBuffer.append("/").append(URLEncoder.encode(s2[0], "UTF-8")); if (s2.length > 1) { // there is a jsessionid so let's add it again without encoding pathBuffer.append(";").append(s2[1]); } } } else { pathBuffer = new StringBuffer(""); } path = targetURL.getProtocol() + "://" + targetURL.getHost() + (targetURL.getPort() == -1 ? "" : ":" + targetURL.getPort()) + pathBuffer.toString() + (targetURL.getQuery() != null ? "?" + targetURL.getQuery() : ""); // Create a get method for accessing the url. HttpMethodBase httpMethod = new GetMethod(path); // Set a default retry handler (see httpclient doc). httpMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); String contentCharset = httpClient.getParams().getContentCharset(); // Get the response of the url in a string. httpClient.getParams().setContentCharset(contentCharset); return getResponse(path, renderContext, resource, chain, httpMethod, httpClient); }