List of usage examples for java.net HttpURLConnection HTTP_NOT_AUTHORITATIVE
int HTTP_NOT_AUTHORITATIVE
To view the source code for java.net HttpURLConnection HTTP_NOT_AUTHORITATIVE.
Click Source Link
From source file:Main.java
public static void main(String[] argv) throws Exception { HttpURLConnection.setFollowRedirects(false); HttpURLConnection con = (HttpURLConnection) new URL("http://www.google.coom").openConnection(); con.setRequestMethod("HEAD"); System.out.println(con.getResponseCode() == HttpURLConnection.HTTP_NOT_AUTHORITATIVE); }
From source file:com.adaptris.http.HttpClientTransport.java
/** * Is the HTTP response code considered to be a success. * <p>//from w w w.j a v a 2 s . c o m * There are 7 possible HTTP codes that signify success or partial success :- * <code>200,201,202,203,204,205,206</code> * </p> * * @return true if the transaction was successful. */ private boolean wasSuccessful(HttpSession session) { boolean rc = false; switch (session.getResponseLine().getResponseCode()) { case HttpURLConnection.HTTP_ACCEPTED: case HttpURLConnection.HTTP_CREATED: case HttpURLConnection.HTTP_NO_CONTENT: case HttpURLConnection.HTTP_NOT_AUTHORITATIVE: case HttpURLConnection.HTTP_OK: case HttpURLConnection.HTTP_PARTIAL: case HttpURLConnection.HTTP_RESET: { rc = true; break; } default: { rc = false; break; } } return rc; }
From source file:org.openrdf.http.client.SesameSession.java
public String getNamespace(String prefix) throws IOException, RepositoryException, UnauthorizedException { checkRepositoryURL();//w ww . j a v a 2 s. c o m HttpUriRequest method = new HttpGet(Protocol.getNamespacePrefixLocation(getQueryURL(), prefix)); try { HttpResponse response = execute(method); int code = response.getStatusLine().getStatusCode(); if (code == HttpURLConnection.HTTP_OK || code == HttpURLConnection.HTTP_NOT_AUTHORITATIVE) { return EntityUtils.toString(response.getEntity()); } else { EntityUtils.consume(response.getEntity()); return null; } } catch (RepositoryException e) { throw e; } catch (OpenRDFException e) { throw new RepositoryException(e); } }
From source file:org.eclipse.rdf4j.http.client.RDF4JProtocolSession.java
public String getNamespace(String prefix) throws IOException, RepositoryException, UnauthorizedException { checkRepositoryURL();//from w w w.java2s. com HttpGet method = new HttpGet(Protocol.getNamespacePrefixLocation(getQueryURL(), prefix)); try { HttpResponse response = execute(method); int code = response.getStatusLine().getStatusCode(); if (code == HttpURLConnection.HTTP_OK || code == HttpURLConnection.HTTP_NOT_AUTHORITATIVE) { return EntityUtils.toString(response.getEntity()); } else { EntityUtils.consume(response.getEntity()); return null; } } catch (RepositoryException e) { throw e; } catch (RDF4JException e) { throw new RepositoryException(e); } finally { method.reset(); } }
From source file:org.openrdf.http.client.SparqlSession.java
/** * Convenience method to deal with HTTP level errors of tuple, graph and * boolean queries in the same way. This method aborts the HTTP connection. * //from www. j a va2 s . co m * @param method * @throws OpenRDFException */ protected HttpResponse executeOK(HttpUriRequest method) throws IOException, OpenRDFException { boolean fail = true; HttpResponse response = execute(method); try { int httpCode = response.getStatusLine().getStatusCode(); if (httpCode == HttpURLConnection.HTTP_OK || httpCode == HttpURLConnection.HTTP_NOT_AUTHORITATIVE) { fail = false; return response; // everything OK, control flow can continue } else { // trying to contact a non-Sesame server? throw new RepositoryException("Failed to get server protocol; no such resource on this server: " + method.getURI().toString()); } } finally { if (fail) { EntityUtils.consumeQuietly(response.getEntity()); } } }
From source file:org.eclipse.rdf4j.http.client.SPARQLProtocolSession.java
/** * Convenience method to deal with HTTP level errors of tuple, graph and boolean queries in the same way. * This method aborts the HTTP connection. * //from w w w .j a v a 2 s .c om * @param method * @throws RDF4JException */ protected HttpResponse executeOK(HttpUriRequest method) throws IOException, RDF4JException { boolean fail = true; HttpResponse response = execute(method); try { int httpCode = response.getStatusLine().getStatusCode(); if (httpCode == HttpURLConnection.HTTP_OK || httpCode == HttpURLConnection.HTTP_NOT_AUTHORITATIVE) { fail = false; return response; // everything OK, control flow can continue } else { // trying to contact a non-SPARQL server? throw new RepositoryException("Failed to get server protocol; no such resource on this server: " + method.getURI().toString()); } } finally { if (fail) { EntityUtils.consumeQuietly(response.getEntity()); } } }