Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
[maven-scm] copy for tag wink-1.0-incubating
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas L. Gallardo committed Nov 3, 2009
2 parents 36a33b4 + 6dc0561 commit 602e051
Show file tree
Hide file tree
Showing 37 changed files with 1,581 additions and 656 deletions.
504 changes: 0 additions & 504 deletions LICENSE

Large diffs are not rendered by default.

21 changes: 0 additions & 21 deletions NOTICE
Expand Up @@ -4,24 +4,3 @@ Copyright 2009 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

This product includes software developed by the JSON.org distributed under json license

This product includes software, StAX API (http://stax.codehaus.org/) distributed under Apache-2.0 license

This product includes software developed for the JAXB Reference Implementation project (https://jaxb.dev.java.net/) distributed under CDDL Version 1.0 license

This product includes software, JSR-311 (https://jsr311.dev.java.net/) distributed under CDDL Version 1.0 license

This product includes software, JavaBeans Activation Framework (http://java.sun.com/javase/technologies/desktop/javabeans/jaf/) distributed under CDDL Version 1.0 license

This product includes software, SLF4J (http://www.slf4j.org/) distributed under slf4j license

This product includes software, Spring (http://www.springsource.org/) distributed under Apache-2.0 license

This product includes software, htmlparser (http://about.validator.nu/htmlparser/) distributed under MIT license

This product includes software, Jaxen (http://jaxen.codehaus.org/) distributed under Jaxen license

This product includes software, Jettison (http://jettison.codehaus.org/) distributed under Apache-2.0 license

This product includes software, Woodstox (http://woodstox.codehaus.org/) distributed under Apache-2.0 license
10 changes: 10 additions & 0 deletions wink-client-apache-httpclient/pom.xml
Expand Up @@ -42,6 +42,16 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<!--
Expand Down
Expand Up @@ -63,8 +63,9 @@ public ApacheHttpClientConnectionHandler(HttpClient httpclient) {
}

public ClientResponse handle(ClientRequest request, HandlerContext context) throws Exception {
HttpResponse response = null;
try {
HttpResponse response = processRequest(request, context);
response = processRequest(request, context);
return processResponse(request, context, response);
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -174,12 +175,25 @@ private ClientResponse processResponse(ClientRequest request,
return response;
}

private ClientResponse createResponse(ClientRequest request, HttpResponse httpResponse) {
ClientResponse response = new ClientResponseImpl();
private ClientResponse createResponse(ClientRequest request, final HttpResponse httpResponse) {
final ClientResponseImpl response = new ClientResponseImpl();
StatusLine statusLine = httpResponse.getStatusLine();
response.setStatusCode(statusLine.getStatusCode());
response.setMessage(statusLine.getReasonPhrase());
response.getAttributes().putAll(request.getAttributes());
response.setContentConsumer(new Runnable() {

public void run() {
HttpEntity entity = httpResponse.getEntity();
if (entity != null) {
try {
entity.consumeContent();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
});
processResponseHeaders(response, httpResponse);
return response;
}
Expand Down
Expand Up @@ -107,4 +107,15 @@ public interface ClientResponse extends BaseRequestResponse {
* @param entity response entity to set
*/
public void setEntity(Object entity);

/**
* Consumes entity content. The real behavior of this method depends on the
* actual implementation. It's needed to call this method, if the calling
* code decides not to handle content.
* <p>
* There is no need to call this method, if getEntity() was invoked.
* <p>
* Calling this method multiple times will not cause an error.
*/
public void consumeContent();
}
Expand Up @@ -39,9 +39,10 @@

public class ClientResponseImpl extends BaseRequestResponseImpl implements ClientResponse {

private Object entity;
private String message;
private int status;
private Object entity;
private String message;
private int status;
private Runnable contentConsumer;

public <T> T getEntity(Class<T> type) {
return getEntity(type, type);
Expand Down Expand Up @@ -127,7 +128,22 @@ private <T> T readEntity(Class<T> type, Type genericType, InputStream is) {
throw new ClientRuntimeException(e);
} finally {
RuntimeContextTLS.setRuntimeContext(saved);
consumeContent();
}
}

public void consumeContent() {
if (contentConsumer != null) {
contentConsumer.run();
}
}

public void setContentConsumer(Runnable contentConsumer) {
this.contentConsumer = contentConsumer;
}

public Runnable getContentConsumer() {
return contentConsumer;
}

}

0 comments on commit 602e051

Please sign in to comment.