void forceClose() throws RestCallException { softClose = false; close(); }
void forceClose() throws RestCallException { softClose = false; close(); }
void forceClose() throws RestCallException { softClose = false; close(); }
/** * Connects to the remote resource (if {@code connect()} hasn't already been called) and returns the value of * an HTTP header on the response. * * <p> * Useful if you're only interested in a particular header value from the response and not the body of the response. * * <p> * The response entity is discarded unless one of the pipe methods have been specified to pipe the output to an * output stream or writer. * * @param name The header name. * @return The response header as a string, or <jk>null</jk> if the header was not found. * @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. * @throws IOException If an exception occurred while streaming was already occurring. */ public String getResponseHeader(String name) throws IOException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); return h == null ? null : h.getValue(); } catch (IOException e) { isFailed = true; close(); throw e; } }
/** * Connects to the remote resource (if {@code connect()} hasn't already been called) and returns the value of * an HTTP header on the response. * * <p> * Useful if you're only interested in a particular header value from the response and not the body of the response. * * <p> * The response entity is discarded unless one of the pipe methods have been specified to pipe the output to an * output stream or writer. * * @param name The header name. * @return The response header as a string, or <jk>null</jk> if the header was not found. * @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. * @throws IOException If an exception occurred while streaming was already occurring. */ public String getResponseHeader(String name) throws IOException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); return h == null ? null : h.getValue(); } catch (IOException e) { isFailed = true; close(); throw e; } }
/** * Connects to the remote resource (if {@code connect()} hasn't already been called) and returns the value of * an HTTP header on the response. * * <p> * Useful if you're only interested in a particular header value from the response and not the body of the response. * * <p> * The response entity is discarded unless one of the pipe methods have been specified to pipe the output to an * output stream or writer. * * @param name The header name. * @return The response header as a string, or <jk>null</jk> if the header was not found. * @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. * @throws IOException If an exception occurred while streaming was already occurring. */ public String getResponseHeader(String name) throws IOException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); return h == null ? null : h.getValue(); } catch (IOException e) { isFailed = true; close(); throw e; } }
/** * Connects to the remote resource (if {@code connect()} hasn't already been called) and returns the HTTP response * message body as plain text. * * <p> * The response entity is discarded unless one of the pipe methods have been specified to pipe the output to an * output stream or writer. * * @return The response as a string. * @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. * @throws IOException If an exception occurred while streaming was already occurring. */ public String getResponseAsString() throws IOException { try (Reader r = getReader()) { return read(r).toString(); } catch (IOException e) { isFailed = true; close(); throw e; } }
/** * Connects to the remote resource (if {@code connect()} hasn't already been called) and returns the HTTP response * message body as plain text. * * <p> * The response entity is discarded unless one of the pipe methods have been specified to pipe the output to an * output stream or writer. * * @return The response as a string. * @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. * @throws IOException If an exception occurred while streaming was already occurring. */ public String getResponseAsString() throws IOException { try (Reader r = getReader()) { return read(r).toString(); } catch (IOException e) { isFailed = true; close(); throw e; } }
/** * Connects to the remote resource (if {@code connect()} hasn't already been called) and returns the HTTP response * message body as plain text. * * <p> * The response entity is discarded unless one of the pipe methods have been specified to pipe the output to an * output stream or writer. * * @return The response as a string. * @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. * @throws IOException If an exception occurred while streaming was already occurring. */ public String getResponseAsString() throws IOException { try (Reader r = getReader()) { return read(r).toString(); } catch (IOException e) { isFailed = true; close(); throw e; } }
/** * Same as {@link #getResponseHeader(String)} except parses the header value using the specified part parser and schema. * * @param name The header name. * @param partParser The part parser to use for parsing the header. * @param schema The part schema. Can be <jk>null</jk>. * @param type The type to convert the part into. * @param args The type arguments to convert the part into. * @return The parsed part. * @throws IOException * @throws ParseException */ public <T> T getResponseHeader(HttpPartParser partParser, HttpPartSchema schema, String name, Type type, Type...args) throws IOException, ParseException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); if (h == null) return null; String hs = h.getValue(); if (partParser == null) partParser = client.getPartParser(); return partParser.parse(schema, hs, type, args); } catch (IOException e) { isFailed = true; close(); throw e; } }
/** * Same as {@link #getResponseHeader(String)} except parses the header value using the specified part parser and schema. * * @param name The header name. * @param partParser The part parser to use for parsing the header. * @param schema The part schema. Can be <jk>null</jk>. * @param type The type to convert the part into. * @param args The type arguments to convert the part into. * @return The parsed part. * @throws IOException * @throws ParseException */ public <T> T getResponseHeader(HttpPartParser partParser, HttpPartSchema schema, String name, Type type, Type...args) throws IOException, ParseException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); if (h == null) return null; String hs = h.getValue(); if (partParser == null) partParser = client.getPartParser(); return partParser.parse(schema, hs, type, args); } catch (IOException e) { isFailed = true; close(); throw e; } }
/** * Same as {@link #getResponseHeader(String)} except parses the header value using the specified part parser and schema. * * @param name The header name. * @param partParser The part parser to use for parsing the header. * @param schema The part schema. Can be <jk>null</jk>. * @param type The type to convert the part into. * @param args The type arguments to convert the part into. * @return The parsed part. * @throws IOException * @throws ParseException */ public <T> T getResponseHeader(HttpPartParser partParser, HttpPartSchema schema, String name, Type type, Type...args) throws IOException, ParseException { try { HttpResponse r = getResponse(); Header h = r.getFirstHeader(name); if (h == null) return null; String hs = h.getValue(); if (partParser == null) partParser = client.getPartParser(); return partParser.parse(schema, hs, type, args); } catch (IOException e) { isFailed = true; close(); throw e; } }
throw new RestCallException(e).setHttpResponse(response); } finally { close();
throw new RestCallException(e).setHttpResponse(response); } finally { close();
throw new RestCallException(e).setHttpResponse(response); } finally { close();
close(); throw e;
close(); throw e;