List of usage examples for org.apache.commons.httpclient HttpMethod getResponseHeader
public abstract Header getResponseHeader(String paramString);
From source file:com.thoughtworks.go.agent.service.AgentUpgradeService.java
private void validateIfLatestAgent(String md5, HttpMethod method) { final Header newAgentMd5 = method.getResponseHeader(SystemEnvironment.AGENT_CONTENT_MD5_HEADER); if (!md5.equals(newAgentMd5.getValue())) { LOGGER.fatal(String.format( "[Agent Upgrade] Agent needs to upgrade itself. Currently has md5 [%s] but server version has md5 [%s]. Exiting.", md5, newAgentMd5));/* ww w .java2 s .com*/ jvmExit(); } }
From source file:com.thoughtworks.go.agent.service.AgentUpgradeService.java
private void validateIfLatestPluginZipAvailable(String agentPluginsMd5, HttpMethod method) { final Header newLauncherMd5 = method.getResponseHeader(SystemEnvironment.AGENT_PLUGINS_ZIP_MD5_HEADER); if (!"".equals(agentPluginsMd5)) { if (!agentPluginsMd5.equals(newLauncherMd5.getValue())) { LOGGER.fatal(String.format( "[Agent Launcher Upgrade] Agent needs to upgrade its plugins. Currently agents plugins has md5 [%s] but server's latest plugins md5 has md5 [%s]. Exiting.", agentPluginsMd5, newLauncherMd5)); jvmExit();/*from www . ja va 2s .co m*/ } } }
From source file:com.thoughtworks.go.agent.service.AgentUpgradeService.java
private void validateIfLatestLauncher(String launcherMd5, HttpMethod method) { final Header newLauncherMd5 = method.getResponseHeader(SystemEnvironment.AGENT_LAUNCHER_CONTENT_MD5_HEADER); if (!"".equals(launcherMd5)) { if (!launcherMd5.equals(newLauncherMd5.getValue())) { LOGGER.fatal(String.format( "[Agent Launcher Upgrade] Agent needs to upgrade its launcher. Currently launcher has md5 [%s] but server's latest launcher has md5 [%s]. Exiting.", launcherMd5, newLauncherMd5)); jvmExit();//from w w w.j a v a2 s . co m } } }
From source file:com.hp.alm.ali.rest.client.filter.IssueTicketFilter.java
@Override public Filter applyFilter(Filter filter, HttpMethod method, ResultInfo resultInfo) { Header contentType = method.getResponseHeader("Content-type"); if (method.getStatusCode() == 500 && contentType != null && contentType.getValue().contains("text/html")) { return new MyFilter(filter, resultInfo); } else {//from w w w . j a va 2 s . c om return filter; } }
From source file:com.cyberway.issue.crawler.extractor.ExtractorHTTP.java
public void innerProcess(CrawlURI curi) { if (!curi.isHttpTransaction() || curi.getFetchStatus() <= 0) { // If not http or if an error status code, skip. return;/* w ww. j av a 2s. co m*/ } numberOfCURIsHandled++; HttpMethod method = (HttpMethod) curi.getObject(A_HTTP_TRANSACTION); addHeaderLink(curi, method.getResponseHeader("Location")); addHeaderLink(curi, method.getResponseHeader("Content-Location")); }
From source file:gov.nih.nci.cabio.portal.portlet.RESTProxyServletController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { try {//ww w . j a v a2 s . c o m String relativeURL = request.getParameter("relativeURL"); if (relativeURL == null) { log.error("Null relativeURL parameter"); return null; } String qs = request.getQueryString(); if (qs == null) { qs = ""; } qs = qs.replaceFirst("relativeURL=(.*?)&", ""); qs = URLDecoder.decode(qs, "UTF-8"); String url = caBIORestURL + relativeURL + "?" + qs; log.info("Proxying URL: " + url); URI uri = new URI(url, false); HttpClient client = new HttpClient(); HttpMethod method = new GetMethod(); method.setURI(uri); client.executeMethod(method); response.setContentType(method.getResponseHeader("Content-Type").getValue()); CopyUtils.copy(method.getResponseBodyAsStream(), response.getOutputStream()); } catch (Exception e) { throw new ServletException("Unable to connect to caBIO", e); } return null; }
From source file:com.javector.soaj.deploy.invocation.TestInvocation.java
public void testInvocation() throws Exception { HttpClient client = new HttpClient(); log.info("Entered TestInvocation.testInvocation."); //TODO factor out the hardcoded http address HttpMethod method = new GetMethod("http://localhost:8080/tester/test"); System.out.println("HTTP GET response code: " + client.executeMethod(method)); Header hdr = method.getResponseHeader("IntegrationTest_SoajEJB30Method"); String response = ""; if (hdr == null) { // check for exception hdr = method.getResponseHeader("IntegrationTest_SoajEJB30Method_Exception"); throw new Exception(hdr.getValue()); } else {//from w w w .java 2 s .c om response = hdr.getValue(); } assertEquals("Hello World", response); }
From source file:com.javector.soaj.deploy.invocation.TestInvocation.java
public void testInvocationEJB21() throws Exception { HttpClient client = new HttpClient(); log.info("Entered InvocationTest_EJB21."); //TODO factor out the hardcoded http address HttpMethod method = new GetMethod("http://localhost:8080/tester/test/ejb21"); System.out.println("HTTP GET response code: " + client.executeMethod(method)); Header hdr = method.getResponseHeader("IntegrationTest_SoajEJB21Method"); String response = ""; if (hdr == null) { // check for exception hdr = method.getResponseHeader("IntegrationTest_SoajEJB21Method_Exception"); throw new Exception(hdr.getValue()); } else {//from w w w .j a v a 2s.c o m response = hdr.getValue(); } assertEquals("Hello World", response); }
From source file:com.zimbra.qa.unittest.TestFileUpload.java
private String getHeaderValue(HttpMethod method, String name) { HeaderElement[] header = method.getResponseHeader(name).getElements(); String value = null;//from www .j ava 2 s.c om if (header.length > 0) { value = header[0].getName(); } return value; }
From source file:it.geosolutions.httpproxy.callback.MimeTypeChecker.java
public void onRemoteResponse(HttpMethod method) throws IOException { Set<String> mimeTypes = config.getMimetypeWhitelist(); if (mimeTypes != null && mimeTypes.size() > 0) { String contentType = method.getResponseHeader("Content-type").getValue(); // ////////////////////////////////// // Trim off extraneous information // ////////////////////////////////// String firstType = contentType.split(";")[0]; if (!mimeTypes.contains(firstType)) { throw new HttpErrorException(403, "Content-type " + firstType + " is not among the ones allowed for this proxy"); }// www.ja v a2s . c o m } }