private static boolean isFuseki(HttpOptions request, HttpClient httpClient, HttpContext httpContext) { try { HttpResponse response = httpClient.execute(request); // Fuseki does not send "Server" in release mode. // (best practice). // All we can do is try for the "Fuseki-Request-ID" String reqId = safeGetHeader(response, "Fuseki-Request-ID"); if ( reqId != null ) return true; // If returning "Server" String serverIdent = safeGetHeader(response, "Server"); if ( serverIdent != null ) { Log.debug(ARQ.getHttpRequestLogger(), "Server: "+serverIdent); boolean isFuseki = serverIdent.startsWith("Apache Jena Fuseki"); if ( !isFuseki ) isFuseki = serverIdent.toLowerCase().contains("fuseki"); return isFuseki; } return false; } catch (IOException ex) { throw new HttpException("Failed to check for a Fuseki server", ex); } }
private static boolean isFuseki(HttpOptions request, HttpClient httpClient, HttpContext httpContext) { try { HttpResponse response = httpClient.execute(request); // Fuseki does not send "Server" in release mode. // (best practice). // All we can do is try for the "Fuseki-Request-ID" String reqId = safeGetHeader(response, "Fuseki-Request-ID"); if ( reqId != null ) return true; // If returning "Server" String serverIdent = safeGetHeader(response, "Server"); if ( serverIdent != null ) { Log.debug(ARQ.getHttpRequestLogger(), "Server: "+serverIdent); boolean isFuseki = serverIdent.startsWith("Apache Jena Fuseki"); if ( !isFuseki ) isFuseki = serverIdent.toLowerCase().contains("fuseki"); return isFuseki; } return false; } catch (IOException ex) { throw new HttpException("Failed to check for a Fuseki server", ex); } }
private InputStream execPost() throws QueryExceptionHTTP { URL target = null; try { target = new URL(serviceURL); } catch (MalformedURLException malEx) { throw new QueryExceptionHTTP(0, "Malformed URL: " + malEx); } log.trace("POST " + target.toExternalForm()); ARQ.getHttpRequestLogger().trace(target.toExternalForm()); try { // Get the actual response stream TypedInputStream stream = HttpOp.execHttpPostFormStream(serviceURL, this, contentTypeResult, client, getContext()); if (stream == null) throw new QueryExceptionHTTP(404); return execCommon(stream); } catch (HttpException httpEx) { throw rewrap(httpEx); } }
private InputStream execGet() throws QueryExceptionHTTP { URL target = null; String qs = getQueryString(); ARQ.getHttpRequestLogger().trace(qs); try { if (count() == 0) target = new URL(serviceURL); else target = new URL(serviceURL + (serviceParams ? "&" : "?") + qs); } catch (MalformedURLException malEx) { throw new QueryExceptionHTTP(0, "Malformed URL: " + malEx); } log.trace("GET " + target.toExternalForm()); try { try { // Get the actual response stream TypedInputStream stream = HttpOp.execHttpGet(target.toString(), contentTypeResult, client, getContext()); if (stream == null) throw new QueryExceptionHTTP(404); return execCommon(stream); } catch (HttpException httpEx) { // Back-off and try POST if something complain about long URIs if (httpEx.getResponseCode() == 414) return execPost(); throw httpEx; } } catch (HttpException httpEx) { throw rewrap(httpEx); } }