public String getStatusText() { return getStatusLine(); }
public String getStatusText() { return getStatusLine(); }
private void doConnect(HTTPMethod method) throws IOException { // Execute the method. int statusCode = method.execute(); if (statusCode == 404) throw new FileNotFoundException(url + " " + method.getStatusLine()); if (statusCode >= 300) throw new IOException(url + " " + method.getStatusLine()); if (debugDetails) { // request headers dont seem to be available until after execute() printHeaders("Request: " + method.getName() + " " + method.getPath(), method.getRequestHeaders()); printHeaders("Response: " + method.getStatusCode(), method.getResponseHeaders()); } }
private void doConnect(HTTPMethod method) throws IOException { // Execute the method. int statusCode = method.execute(); if (statusCode == 404) throw new FileNotFoundException(url + " " + method.getStatusLine()); if (statusCode >= 300) throw new IOException(url + " " + method.getStatusLine()); if (debugDetails) { // request headers dont seem to be available until after execute() printHeaders("Request: " + method.getURI().toString(), method.getRequestHeaders()); printHeaders("Response: " + method.getStatusCode(), method.getResponseHeaders()); } }
private static String getErrorMessage(HTTPMethod method) { String path = method.getURI().toString(); String status = method.getStatusLine(); String content = method.getResponseAsString(); return (content == null) ? path + " " + status : path + " " + status + "\n " + content; }
private static String getErrorMessage(HTTPMethod method) { String path = method.getURI().toString(); String status = method.getStatusLine(); String content = method.getResponseAsString(); return (content == null) ? path+" "+status : path+" "+status +"\n "+content; }
private static String getErrorMessage(HTTPMethod method) { String path = method.getURI().toString(); String status = method.getStatusLine(); String content = method.getResponseAsString(); return (content == null) ? status + " " + path : status + " " + path +"\n "+content; }
private void checkHeaders(HTTPMethod method) { if(debugHeaders) { DAPNode.log.debug("\nOpenConnection Headers for " + method.getPath()); DAPNode.log.debug("Status Line: " + method.getStatusLine()); } Header[] responseHeaders = method.getResponseHeaders(); for(int i1 = 0; i1 < responseHeaders.length; i1++) { Header responseHeader = responseHeaders[i1]; if(debugHeaders) DAPNode.log.debug(" " + responseHeader); String key = responseHeader.getName(); String value = responseHeader.getValue(); if(key.equals("Last-Modified")) { lastModified = value; if(debugHeaders) DAPNode.log.debug(" **found lastModified = " + lastModified); } else if(key.equals("X-Last-Extended")) { lastExtended = value; if(debugHeaders) DAPNode.log.debug(" **found lastExtended = " + lastExtended); } else if(key.equals("X-Last-Modified-Invalid")) { lastModifiedInvalid = value; if(debugHeaders) DAPNode.log.debug(" **found lastModifiedInvalid = " + lastModifiedInvalid); } } if(debugHeaders) DAPNode.log.debug("OpenConnection Headers for " + method.getPath()); }
public static InputStream sendQuery(HTTPSession session, String remoteURI, String query) throws IOException { long start = System.currentTimeMillis(); StringBuilder sbuff = new StringBuilder(remoteURI); sbuff.append("?"); sbuff.append(query); if (showRequest) System.out.printf(" CdmRemote sendQuery= %s", sbuff); HTTPMethod method = HTTPFactory.Get(session, sbuff.toString()); try { int statusCode = method.execute(); if (statusCode == 404) { throw new FileNotFoundException(method.getPath() + " " + method.getStatusLine()); } else if (statusCode >= 400) { throw new IOException(method.getPath() + " " + method.getStatusLine()); } InputStream stream = method.getResponseBodyAsStream(); if (showRequest) System.out.printf(" took %d msecs %n", System.currentTimeMillis() - start); // Leave the stream open. We must also leave the HTTPMethod open because the two are linked: // calling close() on one object causes the other object to be closed as well. return stream; } catch (IOException e) { // Close the HTTPMethod if there was an exception; otherwise leave it open. method.close(); throw e; } }
throw new FileNotFoundException(method.getPath() + " " + method.getStatusLine()); throw new IOException(method.getPath() + " " + method.getStatusLine());
throw new FileNotFoundException(method.getURL() + " " + method.getStatusLine()); throw new IOException(method.getURL() + " " + method.getStatusLine());
throw new FileNotFoundException(method.getURL() + " " + method.getStatusLine()); throw new IOException(method.getURL() + " " + method.getStatusLine()); throw new FileNotFoundException(method.getPath() + " " + method.getStatusLine()); throw new IOException(method.getPath() + " " + method.getStatusLine());
throw new FileNotFoundException(method.getPath() + " " + method.getStatusLine()); throw new IOException(method.getPath() + " " + method.getStatusLine());