List of usage examples for org.apache.commons.httpclient HttpMethodBase abort
@Override public void abort()
From source file:net.sf.j2ep.requesthandlers.MaxForwardRequestHandler.java
/** * Sets the headers and does some checking for if this request * is meant for the server or for the proxy. This check is done * by looking at the Max-Forwards header. * // w w w . ja v a2 s. c om * @see net.sf.j2ep.model.RequestHandler#process(javax.servlet.http.HttpServletRequest, java.lang.String) */ public HttpMethod process(HttpServletRequest request, String url) throws IOException { HttpMethodBase method = null; if (request.getMethod().equalsIgnoreCase("OPTIONS")) { method = new OptionsMethod(url); } else if (request.getMethod().equalsIgnoreCase("TRACE")) { method = new TraceMethod(url); } else { return null; } try { int max = request.getIntHeader("Max-Forwards"); if (max == 0 || request.getRequestURI().equals("*")) { setAllHeaders(method, request); method.abort(); } else if (max != -1) { setHeaders(method, request); method.setRequestHeader("Max-Forwards", "" + max--); } else { setHeaders(method, request); } } catch (NumberFormatException e) { } return method; }
From source file:com.clarkparsia.sbol.editor.sparql.StardogEndpoint.java
protected void execute(HttpMethodBase post) throws HttpException, IOException, QueryEvaluationException { post.setDoAuthentication(true);/* w ww . j a v a 2s . c o m*/ boolean completed = false; try { int resultCode = client.executeMethod(post); if (resultCode >= 400) { throw new HttpException("Code: " + resultCode + " " + post.getResponseBodyAsString()); } completed = true; } finally { if (!completed) { post.abort(); } } }
From source file:org.eclipse.mylyn.commons.net.WebUtil.java
/** * Releases the connection used by <code>method</code>. If <code>monitor</code> is cancelled the connection is * aborted to avoid blocking./*from w w w .java 2 s .c o m*/ * * @since 3.4 */ public static void releaseConnection(HttpMethodBase method, IProgressMonitor monitor) { if (monitor != null && monitor.isCanceled()) { // force a connection close on cancel to avoid blocking to do reading the remainder of the response method.abort(); } else { try { method.releaseConnection(); } catch (NullPointerException e) { // ignore, see bug 255417 } } }
From source file:org.openrdf.repository.sparql.query.SPARQLGraphQuery.java
public GraphQueryResult evaluate() throws QueryEvaluationException { try {/*w w w . ja v a 2s.c o m*/ BackgroundGraphResult result = null; HttpMethodBase response = getResponse(); try { RDFParser parser = getParser(response); InputStream in = response.getResponseBodyAsStream(); String charset_str = response.getResponseCharSet(); Charset charset; try { charset = Charset.forName(charset_str); } catch (IllegalCharsetNameException e) { // work around for Joseki-3.2 // Content-Type: application/rdf+xml; // charset=application/rdf+xml charset = Charset.forName("UTF-8"); } result = new BackgroundGraphResult(parser, in, charset, getUrl(), response); execute(result); return result; } catch (HttpException e) { throw new QueryEvaluationException(e); } finally { if (result == null) { response.abort(); } } } catch (IOException e) { throw new QueryEvaluationException(e); } }
From source file:org.rssowl.core.internal.connection.DefaultProtocolHandler.java
private void abortAndRelease(HttpMethodBase method) { if (method != null) { method.abort(); method.releaseConnection(); } }