Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@
<parent>
<groupId>com.nesscomputing.components</groupId>
<artifactId>ness-httpclient-parent</artifactId>
<version>2.0.6-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>ness-httpclient</artifactId>
<name>ness-httpclient</name>
<packaging>jar</packaging>
<description>Ness HTTP client component.</description>

<properties>
<ness.root.dir>${project.parent.basedir}</ness.root.dir>
</properties>

<dependencies>
<dependency>
<groupId>com.nesscomputing.components</groupId>
Expand Down Expand Up @@ -66,12 +62,7 @@

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>

<dependency>
<groupId>com.nesscomputing.testing</groupId>
<artifactId>findbugs-annotations</artifactId>
<artifactId>annotations</artifactId>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javax.annotation.Nonnull;

import com.google.common.base.Preconditions;

import com.nesscomputing.httpclient.factory.httpclient4.ApacheHttpClient4Factory;
import com.nesscomputing.httpclient.internal.HttpClientFactory;
import com.nesscomputing.httpclient.internal.HttpClientMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@
import javax.annotation.Nonnull;
import javax.servlet.http.Cookie;

import org.apache.commons.lang3.StringUtils;

import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;

import com.nesscomputing.httpclient.internal.HttpClientBodySource;
import com.nesscomputing.httpclient.internal.HttpClientFactory;
import com.nesscomputing.httpclient.internal.HttpClientHeader;
import com.nesscomputing.httpclient.internal.HttpClientMethod;

import org.apache.commons.lang3.StringUtils;


/**
* A request to a remote server. Composed step-by-step using a builder.
Expand Down Expand Up @@ -433,7 +434,7 @@ public Builder<Type> setContent(Multimap<String,String> kvPairs, String encoding

sb.append(URLEncoder.encode(key, encoding));
sb.append('=');
if (key != null) {
if (value != null) {
sb.append(URLEncoder.encode(value, encoding));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,74 +15,74 @@
*/
package com.nesscomputing.httpclient;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.List;
import java.util.Map;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

/** Response from the remote server. */
public interface HttpClientResponse {
/**
* Returns the status code for the request.
*
* @return the status code, use the related {@link HttpServletRequest} constants
*/
int getStatusCode();
/**
* Returns the status code for the request.
*
* @return the status code, use the related {@link HttpServletRequest} constants
*/
int getStatusCode();

/**
* Returns the status text for the request.
*
* @return the status text
*/
String getStatusText();
/**
* Returns the status text for the request.
*
* @return the status text
*/
String getStatusText();

/**
* Returns an input stream for the response body.
*
* @return the input stream
* @throws IOException on error
*/
InputStream getResponseBodyAsStream() throws IOException;
/**
* Returns an input stream for the response body.
*
* @return the input stream
* @throws IOException on error
*/
InputStream getResponseBodyAsStream() throws IOException;

/** @return the URI of the request. */
URI getUri();
/** @return the URI of the request. */
URI getUri();

/** @return Content type of the response. */
String getContentType();
/** @return Content type of the response. */
String getContentType();

/**
* @return Length of the content, if present. Can be null (not present), -1 (chunked) or 0 (no
* content).
*/
@CheckForNull
Long getContentLength();
/**
* @return Length of the content, if present. Can be null (not present), -1 (chunked) or 0 (no
* content).
*/
@CheckForNull
Long getContentLength();

/** @return Content charset if present in the header. Can be null. */
@CheckForNull
String getCharset();
/** @return Content charset if present in the header. Can be null. */
@CheckForNull
String getCharset();

/**
* @param name the header name
* @return The named header from the response. Response can be null.
*/
@CheckForNull
String getHeader(String name);
/**
* @param name the header name
* @return The named header from the response. Response can be null.
*/
@CheckForNull
String getHeader(String name);

/**
* @param name the header name
* @return all values for the given header. Response can be null.
*/
@CheckForNull
List<String> getHeaders(String name);
/**
* @param name the header name
* @return all values for the given header. Response can be null.
*/
@CheckForNull
List<String> getHeaders(String name);

/** @return Map of header name -> list of values for each header name */
/** @return Map of header name -> list of values for each header name */
@Nonnull
public Map<String, List<String>> getAllHeaders();
Map<String, List<String>> getAllHeaders();

/** @return true if the response redirects to another object. */
boolean isRedirected();
/** @return true if the response redirects to another object. */
boolean isRedirected();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/**
* A content handler. It parses the response from the server and generates the
* content object.
* content object.
*/
public interface HttpClientResponseHandler<T>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@
import com.google.common.base.Preconditions;
import com.google.common.net.HttpHeaders;

import com.nesscomputing.httpclient.HttpClientAuthProvider;
import com.nesscomputing.httpclient.HttpClientConnectionContext;
import com.nesscomputing.httpclient.HttpClientDefaults;
import com.nesscomputing.httpclient.HttpClientObserver;
import com.nesscomputing.httpclient.HttpClientRequest;
import com.nesscomputing.httpclient.HttpClientResponse;
import com.nesscomputing.httpclient.HttpClientResponseHandler;
import com.nesscomputing.httpclient.internal.AlwaysTrustServerTrustManager;
import com.nesscomputing.httpclient.internal.HttpClientBodySource;
import com.nesscomputing.httpclient.internal.HttpClientFactory;
import com.nesscomputing.httpclient.internal.HttpClientHeader;
import com.nesscomputing.httpclient.internal.HttpClientTrustManagerFactory;
import com.nesscomputing.httpclient.internal.MultiTrustManager;
import com.nesscomputing.logging.Log;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.Charsets;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -74,21 +89,6 @@
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;

import com.nesscomputing.httpclient.HttpClientAuthProvider;
import com.nesscomputing.httpclient.HttpClientConnectionContext;
import com.nesscomputing.httpclient.HttpClientDefaults;
import com.nesscomputing.httpclient.HttpClientObserver;
import com.nesscomputing.httpclient.HttpClientRequest;
import com.nesscomputing.httpclient.HttpClientResponse;
import com.nesscomputing.httpclient.HttpClientResponseHandler;
import com.nesscomputing.httpclient.internal.AlwaysTrustServerTrustManager;
import com.nesscomputing.httpclient.internal.HttpClientBodySource;
import com.nesscomputing.httpclient.internal.HttpClientFactory;
import com.nesscomputing.httpclient.internal.HttpClientHeader;
import com.nesscomputing.httpclient.internal.HttpClientTrustManagerFactory;
import com.nesscomputing.httpclient.internal.MultiTrustManager;
import com.nesscomputing.logging.Log;

/** Apache HttpClient4 based implementation of {@link HttpClientFactory}. */
public class ApacheHttpClient4Factory implements HttpClientFactory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import java.security.Principal;
import java.util.List;

import com.nesscomputing.httpclient.HttpClientAuthProvider;

import org.apache.http.auth.AuthScope;
import org.apache.http.auth.BasicUserPrincipal;
import org.apache.http.auth.Credentials;
import org.apache.http.client.CredentialsProvider;

import com.nesscomputing.httpclient.HttpClientAuthProvider;

/**
* An Apache Httpclient credentials provider that uses the internal structures of the tc-httpclient to provide
* credentials.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
package com.nesscomputing.httpclient.factory.httpclient4;


import org.apache.http.HttpEntity;
import org.apache.http.entity.AbstractHttpEntity;
import java.io.IOException;
import java.io.InputStream;

import com.nesscomputing.httpclient.internal.HttpClientBodySource;

import java.io.IOException;
import java.io.InputStream;
import org.apache.http.HttpEntity;
import org.apache.http.entity.AbstractHttpEntity;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package com.nesscomputing.httpclient.factory.httpclient4;

import com.nesscomputing.httpclient.HttpClientResponse;
import com.nesscomputing.logging.Log;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
Expand All @@ -28,6 +25,11 @@

import javax.annotation.Nonnull;

import com.google.common.collect.Lists;

import com.nesscomputing.httpclient.HttpClientResponse;
import com.nesscomputing.logging.Log;

import org.apache.commons.io.input.NullInputStream;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
Expand All @@ -38,8 +40,6 @@
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.util.EntityUtils;

import com.google.common.collect.Lists;

/**
* Apache HttpClient4 implementation of {@link HttpClientResponse}.
*/
Expand Down Expand Up @@ -124,9 +124,9 @@ public List<String> getHeaders(final String name)
return values;
}

@Override
@Override
@Nonnull
public Map<String,List<String>> getAllHeaders() {
public Map<String,List<String>> getAllHeaders() {
Map<String, List<String>> headerMap = new TreeMap<String,
List<String>>(String.CASE_INSENSITIVE_ORDER);

Expand Down Expand Up @@ -196,8 +196,8 @@ public boolean isRedirected()
@Override
public String toString() {
return String.format("InternalResponse [getContentType()=%s, getContentLength()=%s," +
" getCharset()=%s, getAllHeaders()=%s, getStatusCode()=%s," +
" getStatusText()=%s, getUri()=%s, isRedirected()=%s]",
" getCharset()=%s, getAllHeaders()=%s, getStatusCode()=%s," +
" getStatusText()=%s, getUri()=%s, isRedirected()=%s]",
getContentType(), getContentLength(), getCharset(),
getAllHeaders(), getStatusCode(), getStatusText(),
getUri(), isRedirected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
*/
package com.nesscomputing.httpclient.internal;

import javax.net.ssl.X509TrustManager;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.X509TrustManager;

/**
* A wrapper around another X509TrustManager that always trusts server certificates.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ public interface HttpClientFactory
* Stop the Factory. Should free all resources and shut down all connections. After stop() has been called,
* the factory should throw exceptions on all related method calls.
*/
void stop();
void stop();

/**
* True if the start() method was invoked successfully.
*/
boolean isStarted();
/**
* True if the start() method was invoked successfully.
*/
boolean isStarted();

/**
* True if the stop() method was invoked successfully.
*/
boolean isStopped();
boolean isStopped();

/**
* @return a {@link HttpClientConnectionContext} object to modify settings for this factory.
Expand All @@ -59,7 +59,7 @@ public interface HttpClientFactory
* For requests that accept a body, generate a {@link HttpClientBodySource} object that wraps
* the content object. Can return null if no appropriate body source is available.
*/
@CheckForNull
@CheckForNull
HttpClientBodySource getHttpBodySourceFor(Object content);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public class HttpClientHeader

/**
* Create a new header.
* @param name header name
* @param value header value
*/
* @param name header name
* @param value header value
*/
public HttpClientHeader(final String name, final String value)
{
this.name = name;
Expand Down
Loading