Search in sources :

Example 91 with ClientProtocolException

use of org.apache.http.client.ClientProtocolException in project vcell by virtualcell.

the class VCellApiClient method createLocationURI.

/**
 * from org.apache.http.impl.client.DefaultRedirectStrategy
 *
 * @param location
 * @return
 * @throws ProtocolException
 */
private URI createLocationURI(final String location) throws ClientProtocolException {
    try {
        final URIBuilder b = new URIBuilder(new URI(location).normalize());
        final String host = b.getHost();
        if (host != null) {
            b.setHost(host.toLowerCase(Locale.US));
        }
        final String path = b.getPath();
        if (TextUtils.isEmpty(path)) {
            b.setPath("/");
        }
        return b.build();
    } catch (final URISyntaxException ex) {
        throw new ClientProtocolException("Invalid redirect URI: " + location, ex);
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URIBuilder(org.apache.http.client.utils.URIBuilder) ClientProtocolException(org.apache.http.client.ClientProtocolException)

Example 92 with ClientProtocolException

use of org.apache.http.client.ClientProtocolException in project jo-client-platform by jo-source.

the class HttpClientStub method post.

private HttpResponse post(final HttpPost request) throws IOException, ClientProtocolException {
    postInvocations.incrementAndGet();
    final StatusLine status = postStatus.get();
    if (status.getStatusCode() == 200) {
        try {
            queue.put((MessageStub) new ObjectInputStream(request.getEntity().getContent()).readObject());
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
    }
    return new BasicHttpResponse(status);
}
Also used : BasicStatusLine(org.apache.http.message.BasicStatusLine) StatusLine(org.apache.http.StatusLine) BasicHttpResponse(org.apache.http.message.BasicHttpResponse) ClientProtocolException(org.apache.http.client.ClientProtocolException) IOException(java.io.IOException) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

ClientProtocolException (org.apache.http.client.ClientProtocolException)92 IOException (java.io.IOException)80 HttpResponse (org.apache.http.HttpResponse)49 HttpPost (org.apache.http.client.methods.HttpPost)37 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)30 HttpClient (org.apache.http.client.HttpClient)29 HttpGet (org.apache.http.client.methods.HttpGet)25 HttpEntity (org.apache.http.HttpEntity)23 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)20 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)19 InputStreamReader (java.io.InputStreamReader)18 ArrayList (java.util.ArrayList)18 UnsupportedEncodingException (java.io.UnsupportedEncodingException)17 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)14 BufferedReader (java.io.BufferedReader)13 InputStream (java.io.InputStream)13 NameValuePair (org.apache.http.NameValuePair)13 StringEntity (org.apache.http.entity.StringEntity)12 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)11 URI (java.net.URI)10