Permalink
Browse files

Merge branch 'master' into gzip

Conflicts:
	src/test/groovy/groovyx/net/http/thirdparty/GAETest.groovy
  • Loading branch information...
2 parents 0a6151e + 979d8af commit b0a1cb326959c3d315ce18a375f48244661571ad @jgritman committed Oct 31, 2012
View
23 pom.xml
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>http-builder</artifactId>
<groupId>org.codehaus.groovy.modules.http-builder</groupId>
- <version>0.6-SNAPSHOT</version>
+ <version>0.7-SNAPSHOT</version>
<name>HTTP client framework for Groovy</name>
<url>http://groovy.codehaus.org/modules/http-builder/</url>
<inceptionYear>2008</inceptionYear>
@@ -180,7 +179,7 @@
<goal>testCompile</goal>
</goals>
</execution>
- <execution>
+ <!--execution>
<id>release</id>
<phase>deploy</phase>
<goals>
@@ -189,7 +188,7 @@
<configuration>
<source>${pom.basedir}/src/main/script/release_tweet.groovy</source>
</configuration>
- </execution>
+ </execution-->
</executions>
</plugin>
<plugin>
@@ -333,12 +332,8 @@
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
- <!--
- <artifactId>wagon-http</artifactId>
- <artifactId>wagon-webdav</artifactId>
- -->
- <artifactId>wagon-http-lightweight</artifactId>
- <version>1.0</version>
+ <artifactId>wagon-webdav-jackrabbit</artifactId>
+ <version>2.2</version>
</extension>
</extensions>
</build>
@@ -409,10 +404,8 @@
</pluginRepositories>
<scm>
- <developerConnection>scm:https://svn.codehaus.org/gmod/httpbuilder/</developerConnection>
- <connection>scm:http://svn.codehaus.org/gmod/httpbuilder/</connection>
- <tag>trunk</tag>
- <url>http://fisheye.codehaus.org/browse/gmod/httpbuilder/</url>
+ <developerConnection>scm:git:git@github.com:jgritman/httpbuilder.git</developerConnection>
+ <url>http://github.com/jgritman/httpbuilder</url>
</scm>
<distributionManagement>
@@ -82,7 +82,6 @@
* </dl>
*/
public AsyncHTTPBuilder( Map<String, ?> args ) throws URISyntaxException {
- super();
int poolSize = DEFAULT_POOL_SIZE;
ExecutorService threadPool = null;
if ( args != null ) {
@@ -154,8 +153,7 @@ private Object doRequestSuper( RequestConfigDelegate delegate ) throws IOExcepti
protected void initThreadPools( final int poolSize, final ExecutorService threadPool ) {
if (poolSize < 1) throw new IllegalArgumentException("poolSize may not be < 1");
// Create and initialize HTTP parameters
- HttpParams params = client != null ? client.getParams()
- : new BasicHttpParams();
+ HttpParams params = getClient().getParams();
ConnManagerParams.setMaxTotalConnections(params, poolSize);
ConnManagerParams.setMaxConnectionsPerRoute(params,
new ConnPerRouteBean(poolSize));
@@ -171,7 +169,7 @@ protected void initThreadPools( final int poolSize, final ExecutorService thread
ClientConnectionManager cm = new ThreadSafeClientConnManager(
params, schemeRegistry );
- super.client = new DefaultHttpClient( cm, params );
+ setClient(new DefaultHttpClient( cm, params ));
this.threadPool = threadPool != null ? threadPool :
new ThreadPoolExecutor( poolSize, poolSize, 120, TimeUnit.SECONDS,
@@ -130,9 +130,9 @@ public void certificate( String certURL, String password )
*/
public void oauth( String consumerKey, String consumerSecret,
String accessToken, String secretToken ) {
- this.builder.client.removeRequestInterceptorByClass( OAuthSigner.class );
+ this.builder.getClient().removeRequestInterceptorByClass( OAuthSigner.class );
if ( consumerKey != null )
- this.builder.client.addRequestInterceptor( new OAuthSigner(
+ this.builder.getClient().addRequestInterceptor( new OAuthSigner(
consumerKey, consumerSecret, accessToken, secretToken ) );
}
@@ -164,7 +164,7 @@
*/
public class HTTPBuilder {
- protected AbstractHttpClient client;
+ private AbstractHttpClient client;
protected URIBuilder defaultURI = null;
protected AuthConfig auth = new AuthConfig( this );
@@ -186,27 +186,11 @@
* Creates a new instance with a <code>null</code> default URI.
*/
public HTTPBuilder() {
- super();
- HttpParams defaultParams = new BasicHttpParams();
- defaultParams.setParameter( CookieSpecPNames.DATE_PATTERNS,
- Arrays.asList("EEE, dd-MMM-yyyy HH:mm:ss z",
- "EEE, dd MMM yyyy HH:mm:ss z") );
- this.client = this.createClient(defaultParams);
- this.setContentEncoding( ContentEncoding.Type.GZIP,
+ setContentEncoding( ContentEncoding.Type.GZIP,
ContentEncoding.Type.DEFLATE );
}
/**
- * Override this method in a subclass to customize creation of the
- * HttpClient instance.
- * @param params
- * @return
- */
- protected AbstractHttpClient createClient( HttpParams params ) {
- return new DefaultHttpClient(params);
- }
-
- /**
* Give a default URI to be used for all request methods that don't
* explicitly take a URI parameter.
* @param defaultURI either a {@link URL}, {@link URI} or object whose
@@ -215,8 +199,7 @@ protected AbstractHttpClient createClient( HttpParams params ) {
* @throws URISyntaxException if the given argument does not represent a valid URI
*/
public HTTPBuilder( Object defaultURI ) throws URISyntaxException {
- this();
- this.setUri( defaultURI );
+ setUri( defaultURI );
}
/**
@@ -231,8 +214,7 @@ public HTTPBuilder( Object defaultURI ) throws URISyntaxException {
* @throws URISyntaxException if the uri argument does not represent a valid URI
*/
public HTTPBuilder( Object defaultURI, Object defaultContentType ) throws URISyntaxException {
- this();
- this.setUri( defaultURI );
+ setUri( defaultURI );
this.defaultContentType = defaultContentType;
}
@@ -474,7 +456,7 @@ protected Object doRequest( final RequestConfigDelegate delegate )
}
HttpResponseDecorator resp = new HttpResponseDecorator(
- client.execute( reqMethod, delegate.getContext() ),
+ getClient().execute( reqMethod, delegate.getContext() ),
delegate.getContext(), null );
try {
int status = resp.getStatusLine().getStatusCode();
@@ -774,7 +756,7 @@ public boolean isAutoAcceptHeader() {
* string that is known by the {@link ContentEncodingRegistry}
*/
public void setContentEncoding( Object... encodings ) {
- this.contentEncodingHandler.setInterceptors( client, encodings );
+ this.contentEncodingHandler.setInterceptors( getClient(), encodings );
}
/**
@@ -829,7 +811,29 @@ public void setHeaders( Map<?,?> headers ) {
* Return the underlying HTTPClient that is used to handle HTTP requests.
* @return the client instance.
*/
- public AbstractHttpClient getClient() { return this.client; }
+ public AbstractHttpClient getClient() {
+ if (client == null) {
+ HttpParams defaultParams = new BasicHttpParams();
+ defaultParams.setParameter( CookieSpecPNames.DATE_PATTERNS,
+ Arrays.asList("EEE, dd-MMM-yyyy HH:mm:ss z", "EEE, dd MMM yyyy HH:mm:ss z") );
+ client = createClient(defaultParams);
+ }
+ return client;
+ }
+
+ public void setClient(AbstractHttpClient client) {
+ this.client = client;
+ }
+
+ /**
+ * Override this method in a subclass to customize creation of the
+ * HttpClient instance.
+ * @param params
+ * @return
+ */
+ protected AbstractHttpClient createClient( HttpParams params ) {
+ return new DefaultHttpClient(params);
+ }
/**
* Used to access the {@link AuthConfig} handler used to configure common
@@ -893,7 +897,7 @@ public void setProxy( String host, int port, String scheme ) {
* @see ClientConnectionManager#shutdown()
*/
public void shutdown() {
- client.getConnectionManager().shutdown();
+ getClient().getConnectionManager().shutdown();
}
View
@@ -8,6 +8,14 @@
Change Log
See the {{{./jira-report.html}JIRA Report}} for a comprehensive change list.
+* v0.6.0 - Oct 16 2012
+ * Now requires Groovy 1.8
+
+ * Upgrade HttpClient dependency to 4.2.1
+
+ * Upgrade Nekohtml dependency to 1.9.16
+
+ * Changed to use Groovy's native JsonSlurper to consume JSON, rather than jsonlib
* v0.5.2 - 26 Dec 2011
View
@@ -10,6 +10,12 @@ News
You can also follow project updates on {{{http://twitter.com/httpbuilder}Twitter}}
+* 16 Oct 2012 - 0.6.0 released, source now hosted on Github
+
+ The 0.6.0 release is now available which takes care of upgrading some older dependencies.
+
+ The source code is now {{{https://github.com/jgritman/httpbuilder}hosted on Github}}
+
* 26 Dec 2011 - 0.5.2 finally finally released for reals
With so many other projects, HTTPBuilder has taken a back seat, to say the least.
@@ -21,6 +21,7 @@
*/
package groovyx.net.http
+import org.junit.Ignore
import org.junit.Test
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
@@ -74,6 +75,7 @@ public class AsyncHTTPBuilderTest {
println 'done.'
}
+ @Ignore
@Test public void testDefaultConstructor() {
def http = new AsyncHTTPBuilder()
def resp = http.get( uri:'http://ajax.googleapis.com',
@@ -15,6 +15,7 @@ import org.apache.commons.io.IOUtils
import org.apache.http.client.HttpResponseException
import org.apache.http.params.HttpConnectionParams
import org.apache.xml.resolver.tools.CatalogResolver
+import org.junit.Ignore
import org.junit.Test
class HTTPBuilderTest {
@@ -275,6 +276,7 @@ class HTTPBuilderTest {
/* http://googlesystem.blogspot.com/2008/04/google-search-rest-api.html
* http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Earth%20Day
*/
+ @Ignore
@Test public void testJSON() {
def builder = new HTTPBuilder()
@@ -283,7 +285,7 @@ class HTTPBuilderTest {
builder.request('http://ajax.googleapis.com',GET,JSON) {
uri.path = '/ajax/services/search/web'
- uri.query = [ v:'1.0', q: 'Calvin and Hobbes' ]
+ uri.query = [ v:'1.0', q: 'Earth Day' ]
//UA header required to get Google to GZIP response:
headers.'User-Agent' = "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.4) Gecko/2008111319 Ubuntu/8.10 (intrepid) Firefox/3.0.4"
response.success = { resp, json ->
Oops, something went wrong.

0 comments on commit b0a1cb3

Please sign in to comment.