/** * Returns access to the {@link HttpResponse} returned by {@link HttpClient#execute(HttpUriRequest)}. * * <p> * Returns <jk>null</jk> if {@link #connect()} has not yet been called. * * @return The HTTP response object. * @throws IOException */ public HttpResponse getResponse() throws IOException { connect(); return response; }
/** * Returns access to the {@link HttpResponse} returned by {@link HttpClient#execute(HttpUriRequest)}. * * <p> * Returns <jk>null</jk> if {@link #connect()} has not yet been called. * * @return The HTTP response object. * @throws IOException */ public HttpResponse getResponse() throws IOException { connect(); return response; }
/** * Returns access to the {@link HttpResponse} returned by {@link HttpClient#execute(HttpUriRequest)}. * * <p> * Returns <jk>null</jk> if {@link #connect()} has not yet been called. * * @return The HTTP response object. * @throws IOException */ public HttpResponse getResponse() throws IOException { connect(); return response; }
/** * Connects to the REST resource. * * <p> * If this is a <code>PUT</code> or <code>POST</code>, also sends the input to the remote resource.<br> * * <p> * Typically, you would only call this method if you're not interested in retrieving the body of the HTTP response. * Otherwise, you're better off just calling one of the {@link #getReader()}/{@link #getResponse(Class)}/{@link #pipeTo(Writer)} * methods directly which automatically call this method already. * * @return This object (for method chaining). * @throws RestCallException If an exception or <code>400+</code> HTTP status code occurred during the connection attempt. */ public RestCall connect() throws RestCallException { return connect(null); }
/** * Connects to the REST resource. * * <p> * If this is a <code>PUT</code> or <code>POST</code>, also sends the input to the remote resource.<br> * * <p> * Typically, you would only call this method if you're not interested in retrieving the body of the HTTP response. * Otherwise, you're better off just calling one of the {@link #getReader()}/{@link #getResponse(Class)}/{@link #pipeTo(Writer)} * methods directly which automatically call this method already. * * @return This object (for method chaining). * @throws RestCallException If an exception or <code>400+</code> HTTP status code occurred during the connection attempt. */ public RestCall connect() throws RestCallException { return connect(null); }
/** * Connects to the REST resource. * * <p> * If this is a <code>PUT</code> or <code>POST</code>, also sends the input to the remote resource.<br> * * <p> * Typically, you would only call this method if you're not interested in retrieving the body of the HTTP response. * Otherwise, you're better off just calling one of the {@link #getReader()}/{@link #getResponse(Class)}/{@link #pipeTo(Writer)} * methods directly which automatically call this method already. * * @return This object (for method chaining). * @throws RestCallException If an exception or <code>400+</code> HTTP status code occurred during the connection attempt. */ public RestCall connect() throws RestCallException { return connect(null); }
/** * Returns the value of the <code>Content-Length</code> header. * * @return The value of the <code>Content-Length</code> header, or <code>-1</code> if header is not present. * @throws IOException */ public int getContentLength() throws IOException { connect(); Header h = response.getLastHeader("Content-Length"); if (h == null) return -1; long l = Long.parseLong(h.getValue()); if (l > Integer.MAX_VALUE) return Integer.MAX_VALUE; return (int)l; }
/** * Returns the value of the <code>Content-Length</code> header. * * @return The value of the <code>Content-Length</code> header, or <code>-1</code> if header is not present. * @throws IOException */ public int getContentLength() throws IOException { connect(); Header h = response.getLastHeader("Content-Length"); if (h == null) return -1; long l = Long.parseLong(h.getValue()); if (l > Integer.MAX_VALUE) return Integer.MAX_VALUE; return (int)l; }
/** * Returns the value of the <code>Content-Length</code> header. * * @return The value of the <code>Content-Length</code> header, or <code>-1</code> if header is not present. * @throws IOException */ public int getContentLength() throws IOException { connect(); Header h = response.getLastHeader("Content-Length"); if (h == null) return -1; long l = Long.parseLong(h.getValue()); if (l > Integer.MAX_VALUE) return Integer.MAX_VALUE; return (int)l; }
if (isClosed) throw new IllegalStateException("Method cannot be called. Response has already been consumed."); connect(); if (response == null) throw new RestCallException("Response was null");
if (isClosed) throw new IllegalStateException("Method cannot be called. Response has already been consumed."); connect(); if (response == null) throw new RestCallException("Response was null");
if (isClosed) throw new IllegalStateException("Method cannot be called. Response has already been consumed."); connect(); if (response == null) throw new RestCallException("Response was null");
connect(); try { StatusLine status = response.getStatusLine();
connect(); try { StatusLine status = response.getStatusLine();
connect(); try { StatusLine status = response.getStatusLine();
request.setURI(URI.create(h.getValue())); connect();
request.setURI(URI.create(h.getValue())); connect();