List of usage examples for org.apache.commons.httpclient.methods HeadMethod setRequestHeader
@Override public void setRequestHeader(String headerName, String headerValue)
From source file:com.moss.bdbadmin.client.service.BdbClient.java
public void head(IdProof assertion, String path) throws ServiceException { try {/*w w w. ja v a 2 s . c o m*/ HeadMethod method = new HeadMethod(baseUrl + "/" + path); method.setRequestHeader(AuthenticationHeader.HEADER_NAME, AuthenticationHeader.encode(assertion)); int result = httpClient.executeMethod(method); if (result != 200) { throw new ServiceException(result); } } catch (IOException ex) { throw new ServiceFailure(ex); } }
From source file:com.sittinglittleduck.DirBuster.workGenerators.BruteForceURLFuzz.java
public void run() { // checks if the server surports heads requests if (manager.getAuto()) { try {//from ww w .ja v a 2s .c o m URL headurl = new URL(firstPart); HeadMethod httphead = new HeadMethod(headurl.toString()); // set the custom HTTP headers Vector HTTPheaders = manager.getHTTPHeaders(); for (int a = 0; a < HTTPheaders.size(); a++) { HTTPHeader httpHeader = (HTTPHeader) HTTPheaders.elementAt(a); httphead.setRequestHeader(httpHeader.getHeader(), httpHeader.getValue()); } int responceCode = httpclient.executeMethod(httphead); // if the responce code is method not implemented or fails if (responceCode == 501 || responceCode == 400) { // switch the mode to just GET requests manager.setAuto(false); } } catch (MalformedURLException e) { // TODO deal with error } catch (IOException e) { // TODO deal with error } } // deal with the dirs try { // get item from queue DirToCheck tempDirToCheck = dirQueue.take(); // get dir name currentDir = tempDirToCheck.getName(); // get any extention that need to be checked extToCheck = tempDirToCheck.getExts(); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Starting fuzz on " + firstPart + urlFuzzStart + "{dir}" + urlFuzzEnd); started = currentDir; String baseCase = null; // store for the basecase object set to null; BaseCase baseCaseObj = null; try { // get fail responce code for a dir test baseCaseObj = GenBaseCase.genURLFuzzBaseCase(manager, firstPart + urlFuzzStart, urlFuzzEnd); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // baseCaseObj = new BaseCase(null, failcode, true, failurl, baseCase); // call function to generate the brute force makeList(minLen, maxLen, baseCase, baseCaseObj); manager.youAreFinished(); }
From source file:com.sittinglittleduck.DirBuster.workGenerators.WorkerGeneratorURLFuzz.java
/** Thread run method */ public void run() { /*// ww w . j ava 2 s. co m * Read in all the items and create all the work we need to. */ BufferedReader d = null; try { manager.setURLFuzzGenFinished(false); String currentDir = "/"; int failcode = 404; String line; Vector extToCheck = new Vector(10, 5); boolean recursive = true; int passTotal = 0; try { d = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile))); passTotal = 0; while ((line = d.readLine()) != null) { if (!line.startsWith("#")) { passTotal++; } } manager.setTotalPass(passTotal); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } if (manager.getAuto()) { try { URL headurl = new URL(firstPart); HeadMethod httphead = new HeadMethod(headurl.toString()); Vector HTTPheaders = manager.getHTTPHeaders(); for (int a = 0; a < HTTPheaders.size(); a++) { HTTPHeader httpHeader = (HTTPHeader) HTTPheaders.elementAt(a); httphead.setRequestHeader(httpHeader.getHeader(), httpHeader.getValue()); } httphead.setFollowRedirects(Config.followRedirects); int responceCode = httpclient.executeMethod(httphead); if (Config.debug) { System.out.println("DEBUG WokerGen: responce code for head check = " + responceCode); } if (responceCode == 501 || responceCode == 400 || responceCode == 405) { if (Config.debug) { System.out.println( "DEBUG WokerGen: Changing to GET only HEAD test returned 501(method no implmented) or a 400"); } manager.setAuto(false); } } catch (MalformedURLException e) { } catch (IOException e) { } } d = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile))); System.out.println("Starting fuzz on " + firstPart + urlFuzzStart + "{dir}" + urlFuzzEnd); int filesProcessed = 0; BaseCase baseCaseObj = GenBaseCase.genURLFuzzBaseCase(manager, firstPart + urlFuzzStart, urlFuzzEnd); while ((line = d.readLine()) != null) { if (stopMe) { return; } if (!line.startsWith("#")) { String method; if (manager.getAuto() && !baseCaseObj.useContentAnalysisMode() && !baseCaseObj.isUseRegexInstead()) { method = "HEAD"; } else { method = "GET"; } // url encode all the items line = URLEncoder.encode(line); URL currentURL = new URL(firstPart + urlFuzzStart + line + urlFuzzEnd); // BaseCase baseCaseObj = new BaseCase(currentURL, failcode, true, failurl, // baseResponce); // if the base case is null then we need to switch to content anylsis mode workQueue.put(new WorkUnit(currentURL, true, method, baseCaseObj, line)); } Thread.sleep(3); } } catch (InterruptedException ex) { Logger.getLogger(WorkerGeneratorURLFuzz.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(WorkerGeneratorURLFuzz.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(WorkerGeneratorURLFuzz.class.getName()).log(Level.SEVERE, null, ex); } finally { try { d.close(); manager.setURLFuzzGenFinished(true); } catch (IOException ex) { Logger.getLogger(WorkerGeneratorURLFuzz.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.sittinglittleduck.DirBuster.workGenerators.BruteForceWorkGenerator.java
public void run() { boolean recursive = true; // checks if the server surports heads requests if (manager.getAuto()) { try {/*from ww w.ja va2s. c o m*/ URL headurl = new URL(firstPart); HeadMethod httphead = new HeadMethod(headurl.toString()); // set the custom HTTP headers Vector HTTPheaders = manager.getHTTPHeaders(); for (int a = 0; a < HTTPheaders.size(); a++) { HTTPHeader httpHeader = (HTTPHeader) HTTPheaders.elementAt(a); httphead.setRequestHeader(httpHeader.getHeader(), httpHeader.getValue()); } int responceCode = httpclient.executeMethod(httphead); // if the responce code is method not implemented or fails if (responceCode == 501 || responceCode == 400) { // switch the mode to just GET requests manager.setAuto(false); } } catch (MalformedURLException e) { // TODO deal with error } catch (IOException e) { // TODO deal with error } } while ((!dirQueue.isEmpty() || !workQueue.isEmpty()) && recursive) { recursive = manager.isRecursive(); // deal with the dirs try { // get item from queue DirToCheck tempDirToCheck = dirQueue.take(); // get dir name currentDir = tempDirToCheck.getName(); // get any extention that need to be checked extToCheck = tempDirToCheck.getExts(); } catch (InterruptedException e) { e.printStackTrace(); } started = currentDir; if (manager.getDoDirs()) { doingDirs = true; String baseCase = null; // store for the basecase object set to null; BaseCase baseCaseObj = null; URL failurl = null; try { // get fail responce code for a dir test baseCaseObj = GenBaseCase.genBaseCase(manager, firstPart + currentDir, true, null); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // baseCaseObj = new BaseCase(null, failcode, true, failurl, baseCase); // call function to generate the brute force if (failcode != 200) { makeList(minLen, maxLen, null, baseCaseObj); } else { makeList(minLen, maxLen, baseCase, baseCaseObj); } } // end of doing the dirs // brute force files names if (manager.getDoFiles()) { doingDirs = false; String baseCase = null; BaseCase baseCaseObj = null; URL failurl = null; for (int b = 0; b < extToCheck.size(); b++) { ExtToCheck tempExt = (ExtToCheck) extToCheck.elementAt(b); if (tempExt.toCheck()) { fileExtention = ""; if (tempExt.getName().equals(ExtToCheck.BLANK_EXT)) { fileExtention = ""; } else { fileExtention = "." + tempExt.getName(); } try { // deal with the files baseCaseObj = GenBaseCase.genBaseCase(manager, firstPart + currentDir, false, fileExtention); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // call function to generate the brute force if (failcode != 200) { makeList(minLen, maxLen, null, baseCaseObj); } else { makeList(minLen, maxLen, baseCase, baseCaseObj); } } } } finished = started; } manager.youAreFinished(); }
From source file:com.sittinglittleduck.DirBuster.workGenerators.WorkerGenerator.java
/** Thread run method */ public void run() { String currentDir = "/"; int failcode = 404; String line;/*from w w w. j a va2s . c o m*/ Vector extToCheck = new Vector(10, 5); boolean recursive = true; int passTotal = 0; // -------------------------------------------------- try { // find the total number of requests to be made, per pass // based on the fact there is a single entry per line BufferedReader d = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile))); passTotal = 0; while ((line = d.readLine()) != null) { if (!line.startsWith("#")) { passTotal++; } } manager.setTotalPass(passTotal); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } // ------------------------------------------------- // checks if the server surports heads requests if (manager.getAuto()) { try { URL headurl = new URL(firstPart); HeadMethod httphead = new HeadMethod(headurl.toString()); // set the custom HTTP headers Vector HTTPheaders = manager.getHTTPHeaders(); for (int a = 0; a < HTTPheaders.size(); a++) { HTTPHeader httpHeader = (HTTPHeader) HTTPheaders.elementAt(a); /* * Host header has to be set in a different way! */ if (httpHeader.getHeader().startsWith("Host:")) { httphead.getParams().setVirtualHost(httpHeader.getValue()); } else { httphead.setRequestHeader(httpHeader.getHeader(), httpHeader.getValue()); } } httphead.setFollowRedirects(Config.followRedirects); int responceCode = httpclient.executeMethod(httphead); if (Config.debug) { System.out.println("DEBUG WokerGen: responce code for head check = " + responceCode); } // if the responce code is method not implemented or if the head requests return // 400! if (responceCode == 501 || responceCode == 400 || responceCode == 405) { if (Config.debug) { System.out.println( "DEBUG WokerGen: Changing to GET only HEAD test returned 501(method no implmented) or a 400"); } // switch the mode to just GET requests manager.setAuto(false); } } catch (MalformedURLException e) { // TODO deal with error } catch (IOException e) { // TODO deal with error } } // end of checks to see if server surpports head requests int counter = 0; while ((!dirQueue.isEmpty() || !workQueue.isEmpty() || !manager.areWorkersAlive()) && recursive) { // get the dir we are about to process String baseResponce = null; recursive = manager.isRecursive(); BaseCase baseCaseObj = null; // rest the skip skipCurrent = false; // deal with the dirs try { // get item from queue // System.out.println("gen about to take"); DirToCheck tempDirToCheck = dirQueue.take(); // System.out.println("gen taken"); // get dir name currentDir = tempDirToCheck.getName(); // get any extention that need to be checked extToCheck = tempDirToCheck.getExts(); manager.setCurrentlyProcessing(currentDir); } catch (InterruptedException e) { e.printStackTrace(); } started = currentDir; // generate the list of dirs if (manager.getDoDirs()) { // find the fail case for the dir URL failurl = null; try { baseResponce = null; baseCaseObj = GenBaseCase.genBaseCase(manager, firstPart + currentDir, true, null); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // end of dir fail case if (stopMe) { return; } // generate work links try { // readin dir names BufferedReader d = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile))); if (Config.debug) { System.out.println("DEBUG WokerGen: Generating dir list for " + firstPart); } URL currentURL; // add the first item while doing dir's if (counter == 0) { try { String method; if (manager.getAuto() && !baseCaseObj.useContentAnalysisMode() && !baseCaseObj.isUseRegexInstead()) { method = "HEAD"; } else { method = "GET"; } currentURL = new URL(firstPart + currentDir); // System.out.println("first part = " + firstPart); // System.out.println("current dir = " + currentDir); workQueue.put(new WorkUnit(currentURL, true, "GET", baseCaseObj, null)); if (Config.debug) { System.out.println("DEBUG WokerGen: 1 adding dir to work list " + method + " " + currentDir.toString()); } } catch (MalformedURLException ex) { ex.printStackTrace(); } catch (InterruptedException ex) { ex.printStackTrace(); } } // end of dealing with first item int dirsProcessed = 0; // add the rest of the dirs while ((line = d.readLine()) != null) { // code to skip the current work load if (skipCurrent) { // add the totalnumber per pass - the amount process this pass to the // work correction total manager.addToWorkCorrection(passTotal - dirsProcessed); break; } // if the line is not empty or starts with a # if (!line.equalsIgnoreCase("") && !line.startsWith("#")) { line = line.trim(); line = makeItemsafe(line); try { String method; if (manager.getAuto() && !baseCaseObj.useContentAnalysisMode() && !baseCaseObj.isUseRegexInstead()) { method = "HEAD"; } else { method = "GET"; } currentURL = new URL(firstPart + currentDir + line + "/"); // BaseCase baseCaseObj = new BaseCase(currentURL, failcode, true, // failurl, baseResponce); // if the base case is null then we need to switch to content // anylsis mode // System.out.println("Gen about to add to queue"); workQueue.put(new WorkUnit(currentURL, true, method, baseCaseObj, line)); // System.out.println("Gen finshed adding to queue"); if (Config.debug) { System.out.println("DEBUG WokerGen: 2 adding dir to work list " + method + " " + currentURL.toString()); } } catch (MalformedURLException e) { // TODO deal with bad line // e.printStackTrace(); // do nothing if it's malformed, I dont care about them! } catch (InterruptedException e) { e.printStackTrace(); } // if there is a call to stop the work gen then stop! if (stopMe) { return; } dirsProcessed++; } } // end of while } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } // generate the list of files if (manager.getDoFiles()) { baseResponce = null; URL failurl = null; // loop for all the different file extentions for (int b = 0; b < extToCheck.size(); b++) { // only test if we are surposed to ExtToCheck extTemp = (ExtToCheck) extToCheck.elementAt(b); if (extTemp.toCheck()) { fileExtention = ""; if (extTemp.getName().equals(ExtToCheck.BLANK_EXT)) { fileExtention = ""; } else { fileExtention = "." + extTemp.getName(); } try { // get the base for this extention baseCaseObj = GenBaseCase.genBaseCase(manager, firstPart + currentDir, false, fileExtention); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // if the manager has sent the stop command then exit if (stopMe) { return; } try { BufferedReader d = new BufferedReader( new InputStreamReader(new FileInputStream(inputFile))); // if(failcode != 200) // { int filesProcessed = 0; while ((line = d.readLine()) != null) { // code to skip the current work load if (skipCurrent) { manager.addToWorkCorrection(passTotal - filesProcessed); break; } // dont process is the line empty for starts with a # if (!line.equalsIgnoreCase("") && !line.startsWith("#")) { line = line.trim(); line = makeItemsafe(line); try { String method; if (manager.getAuto() && !baseCaseObj.useContentAnalysisMode() && !baseCaseObj.isUseRegexInstead()) { method = "HEAD"; } else { method = "GET"; } URL currentURL = new URL(firstPart + currentDir + line + fileExtention); // BaseCase baseCaseObj = new BaseCase(currentURL, true, // failurl, baseResponce); workQueue.put(new WorkUnit(currentURL, false, method, baseCaseObj, line)); if (Config.debug) { System.out.println("DEBUG WokerGen: adding file to work list " + method + " " + currentURL.toString()); } } catch (MalformedURLException e) { // e.printStackTrace(); // again do nothing as I dont care } catch (InterruptedException e) { e.printStackTrace(); } if (stopMe) { return; } filesProcessed++; } } // end of while // } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } // end of file ext loop } // end of if files finished = started; counter++; try { Thread.sleep(200); } catch (InterruptedException ex) { ex.printStackTrace(); } } // end of main while // System.out.println("Gen FINISHED!"); // manager.youAreFinished(); }
From source file:nl.nn.adapterframework.http.HttpSender.java
protected HttpMethod getMethod(URI uri, String message, ParameterValueList parameters, Map<String, String> headersParamsMap) throws SenderException { try {/*w ww .j av a 2s . c o m*/ boolean queryParametersAppended = false; if (isEncodeMessages()) { message = URLEncoder.encode(message); } StringBuffer path = new StringBuffer(uri.getPath()); if (!StringUtils.isEmpty(uri.getQuery())) { path.append("?" + uri.getQuery()); queryParametersAppended = true; } if (getMethodType().equals("GET")) { if (parameters != null) { queryParametersAppended = appendParameters(queryParametersAppended, path, parameters, headersParamsMap); if (log.isDebugEnabled()) log.debug(getLogPrefix() + "path after appending of parameters [" + path.toString() + "]"); } GetMethod result = new GetMethod(path + (parameters == null ? message : "")); for (String param : headersParamsMap.keySet()) { result.addRequestHeader(param, headersParamsMap.get(param)); } if (log.isDebugEnabled()) log.debug( getLogPrefix() + "HttpSender constructed GET-method [" + result.getQueryString() + "]"); return result; } else if (getMethodType().equals("POST")) { PostMethod postMethod = new PostMethod(path.toString()); if (StringUtils.isNotEmpty(getContentType())) { postMethod.setRequestHeader("Content-Type", getContentType()); } if (parameters != null) { StringBuffer msg = new StringBuffer(message); appendParameters(true, msg, parameters, headersParamsMap); if (StringUtils.isEmpty(message) && msg.length() > 1) { message = msg.substring(1); } else { message = msg.toString(); } } for (String param : headersParamsMap.keySet()) { postMethod.addRequestHeader(param, headersParamsMap.get(param)); } postMethod.setRequestBody(message); return postMethod; } if (getMethodType().equals("PUT")) { PutMethod putMethod = new PutMethod(path.toString()); if (StringUtils.isNotEmpty(getContentType())) { putMethod.setRequestHeader("Content-Type", getContentType()); } if (parameters != null) { StringBuffer msg = new StringBuffer(message); appendParameters(true, msg, parameters, headersParamsMap); if (StringUtils.isEmpty(message) && msg.length() > 1) { message = msg.substring(1); } else { message = msg.toString(); } } putMethod.setRequestBody(message); return putMethod; } if (getMethodType().equals("DELETE")) { DeleteMethod deleteMethod = new DeleteMethod(path.toString()); if (StringUtils.isNotEmpty(getContentType())) { deleteMethod.setRequestHeader("Content-Type", getContentType()); } return deleteMethod; } if (getMethodType().equals("HEAD")) { HeadMethod headMethod = new HeadMethod(path.toString()); if (StringUtils.isNotEmpty(getContentType())) { headMethod.setRequestHeader("Content-Type", getContentType()); } return headMethod; } if (getMethodType().equals("REPORT")) { Element element = XmlUtils.buildElement(message, true); ReportInfo reportInfo = new ReportInfo(element, 0); ReportMethod reportMethod = new ReportMethod(path.toString(), reportInfo); if (StringUtils.isNotEmpty(getContentType())) { reportMethod.setRequestHeader("Content-Type", getContentType()); } return reportMethod; } throw new SenderException( "unknown methodtype [" + getMethodType() + "], must be either POST, GET, PUT or DELETE"); } catch (URIException e) { throw new SenderException(getLogPrefix() + "cannot find path from url [" + getUrl() + "]", e); } catch (DavException e) { throw new SenderException(e); } catch (DomBuilderException e) { throw new SenderException(e); } catch (IOException e) { throw new SenderException(e); } }
From source file:org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient.java
private HeadMethod connectHead(String requestURL, IProgressMonitor monitor) throws IOException, CoreException { hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor); for (int attempt = 0; attempt < 2; attempt++) { // force authentication authenticate(monitor);//w w w .jav a2 s . c om HeadMethod headMethod = new HeadMethod(WebUtil.getRequestPath(requestURL)); if (requestURL.contains(QUERY_DELIMITER)) { headMethod.setQueryString(requestURL.substring(requestURL.indexOf(QUERY_DELIMITER))); } headMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=" //$NON-NLS-1$ //$NON-NLS-2$ + getCharacterEncoding()); // WARNING!! Setting browser compatability breaks Bugzilla // authentication // getMethod.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); // headMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new BugzillaRetryHandler()); headMethod.setDoAuthentication(true); int code; try { code = WebUtil.execute(httpClient, hostConfiguration, headMethod, monitor); } catch (IOException e) { // ignore the response WebUtil.releaseConnection(headMethod, monitor); throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_IO, repositoryUrl.toString(), e)); } if (code == HttpURLConnection.HTTP_OK) { return headMethod; } else if (code == HttpURLConnection.HTTP_UNAUTHORIZED || code == HttpURLConnection.HTTP_FORBIDDEN) { // ignore the response WebUtil.releaseConnection(headMethod, monitor); loggedIn = false; authenticate(monitor); } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) { loggedIn = false; // ignore the response WebUtil.releaseConnection(headMethod, monitor); throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_REPOSITORY_LOGIN, repositoryUrl.toString(), "Proxy authentication required")); //$NON-NLS-1$ } else { // ignore the response WebUtil.releaseConnection(headMethod, monitor); throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_NETWORK, "Http error: " + HttpStatus.getStatusText(code))); //$NON-NLS-1$ // throw new IOException("HttpClient connection error response // code: " + code); } } throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, RepositoryStatus.ERROR_REPOSITORY_LOGIN, "All connection attempts to " + repositoryUrl.toString() //$NON-NLS-1$ + " failed. Please verify connection and authentication information.")); //$NON-NLS-1$ }
From source file:org.mbs3.deliciouschecker.DeliciousChecker.java
/** * @param args/*from w w w .j av a 2 s . c om*/ */ public static void main(String[] args) { System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog"); System.out.println("Connecting to del.icio.us"); Delicious connection = new Delicious(DeliciousChecker.username, DeliciousChecker.password); System.out.println("Getting post data for url verification"); List allPosts = connection.getAllPosts(); Iterator allPostsIterator = allPosts.iterator(); System.out.println("Received " + allPosts.size() + " different posts, checking each"); HttpClient hc = new HttpClient(); hc.getParams().setParameter("http.protocol.version", HttpVersion.HTTP_1_0); hc.getParams().setParameter("http.socket.timeout", new Integer(1000)); while (allPostsIterator.hasNext()) { Post post = (Post) allPostsIterator.next(); //System.out.println("Trying " + post.getHref()); try { HeadMethod hm = new HeadMethod(post.getHref()); hm.setRequestHeader("User-agent", DeliciousChecker.useragent); hm.getParams().setParameter("http.socket.timeout", new Integer(5000)); int response = hc.executeMethod(hm); if (response != 200) { System.out .println(post.getDescription() + "(" + post.getHref() + ") returned HTTP " + response); post.setTag(post.getTag() + " broken"); } } catch (Exception ex) { System.out.println(post.getDescription() + "(" + post.getHref() + ") returned " + ex); post.setTag(post.getTag() + " exception"); } } }