Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Result of upstream merge

  • Loading branch information...
commit 456846e2b56eb09964f65677180bd70ee107d33e 2 parents db26768 + a032796
@kwesterfeld authored
View
33 pom.xml
@@ -35,10 +35,6 @@
<email>matthieu.baechler@gmail.com</email>
</developer>
</developers>
- <properties>
- <maven.compiler.source>1.5</maven.compiler.source>
- <maven.compiler.target>1.5</maven.compiler.target>
- </properties>
<dependencies>
<dependency>
@@ -61,7 +57,7 @@
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
- <version>1.2.1</version>
+ <version>1.2.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
@@ -72,12 +68,35 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>4.1.1</version>
+ <version>4.1.2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
- <version>4.1.1</version>
+ <version>4.1.2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-nop</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
</dependency>
</dependencies>
View
8 src/main/java/com/woonoz/proxy/servlet/HttpEntityEnclosingRequestHandler.java
@@ -67,19 +67,19 @@ protected ClientHeadersHandler createClientHeadersHandler(final UrlRewriter urlR
}
private void copyData(HttpServletRequest request, HttpEntityEnclosingRequestBase httpEntityEnclosingRequestBase) throws FileUploadException, IOException {
- HttpEntity entity = createHttpEntity(request, httpEntityEnclosingRequestBase);
+ HttpEntity entity = createHttpEntity(request);
httpEntityEnclosingRequestBase.setEntity(entity);
}
- private HttpEntity createHttpEntity(HttpServletRequest request, HttpEntityEnclosingRequestBase httpEntityEnclosingRequestBase) throws FileUploadException, IOException {
+ private HttpEntity createHttpEntity(HttpServletRequest request) throws FileUploadException, IOException {
if (ServletFileUpload.isMultipartContent(request)) {
- return createMultipartEntity(request, httpEntityEnclosingRequestBase);
+ return createMultipartEntity(request);
} else {
return new BufferedHttpEntity(new InputStreamEntity(request.getInputStream(), request.getContentLength()));
}
}
- private HttpEntity createMultipartEntity(HttpServletRequest request, HttpEntityEnclosingRequestBase httpEntityEnclosingRequestBase) throws FileUploadException, IOException {
+ private HttpEntity createMultipartEntity(HttpServletRequest request) throws FileUploadException, IOException {
DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
ServletFileUpload servletFileUpload = new ServletFileUpload(diskFileItemFactory);
MultipartEntity multipartEntity = new MultipartEntity();
View
22 src/main/java/com/woonoz/proxy/servlet/HttpRequestHandler.java
@@ -32,8 +32,6 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileUploadException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -42,10 +40,12 @@
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class HttpRequestHandler {
- private static final Log logger = LogFactory.getLog("com.woonoz.proxy.servlet");
+ private static final Logger logger = LoggerFactory.getLogger("com.woonoz.proxy.servlet");
private final HttpServletRequest request;
private final HttpServletResponse response;
private final URL targetServer;
@@ -78,17 +78,11 @@ public void execute() {
ServerHeadersHandler serverHeadersHandler = new ServerHeadersHandler(urlRewriter);
HttpRequestBase httpCommand = null;
try {
- if (logger.isDebugEnabled()) {
- logger.debug("Doing rewrite for uri: " + request.getRequestURL());
- }
+ logger.debug("Doing rewrite for uri: " + request.getRequestURL());
final URI targetUri = urlRewriter.rewriteUri(new URI(request.getRequestURL().toString()));
- if (logger.isDebugEnabled()) {
- logger.debug("Making request for rewritten uri: " + targetUri);
- }
+ logger.debug("Making request for rewritten uri: " + targetUri);
httpCommand = createHttpCommand(targetUri, clientHeadersHandler);
- if (logger.isDebugEnabled()) {
- logger.debug("http client command: " + httpCommand.getRequestLine() + ", headers: " + Arrays.asList(httpCommand.getAllHeaders()));
- }
+ logger.debug("http client command: " + httpCommand.getRequestLine() + ", headers: " + Arrays.asList(httpCommand.getAllHeaders()));
performHttpRequest(httpCommand, response, serverHeadersHandler);
} catch (URISyntaxException e) {
handleException(httpCommand, e);
@@ -153,9 +147,7 @@ private void performHttpRequest(HttpRequestBase requestToServer, HttpServletResp
HttpContext context = new BasicHttpContext();
context.setAttribute(HttpRequestHandler.class.getName(), this);
HttpResponse responseFromServer = client.execute(requestToServer, context);
- if (logger.isDebugEnabled()) {
- logger.debug("Performed request: " + requestToServer.getRequestLine() + " --> " + responseFromServer.getStatusLine());
- }
+ logger.debug("Performed request: " + requestToServer.getRequestLine() + " --> " + responseFromServer.getStatusLine());
responseToClient.setStatus(responseFromServer.getStatusLine().getStatusCode());
copyHeaders(responseFromServer, responseToClient, serverHeadersHandler);
HttpEntity entity = responseFromServer.getEntity();
View
6 src/main/java/com/woonoz/proxy/servlet/UrlRewriterImpl.java
@@ -96,7 +96,7 @@ private Cookie rewriteCookiePathIfNeeded(Cookie cookie) {
private String rewritePathIfNeeded(String requestedPath) {
String servletURI = servletRequest.getContextPath() + servletRequest.getServletPath();
- if (targetServer.getPath().length() != 0 && requestIsSubpathOfServlet(requestedPath)) {
+ if (!targetServer.getPath().isEmpty() && requestIsSubpathOfServlet(requestedPath)) {
return appendPathFragments(targetServer.getPath(), requestedPath.substring(servletURI.length()));
} else {
return requestedPath;
@@ -108,7 +108,7 @@ private static String appendPathFragments(final String firstPart, final String s
}
private static String removeTrailingSlashes(final String text) {
- if (text.length() == 0) {
+ if (text.isEmpty()) {
return text;
}
final CharacterIterator it = new StringCharacterIterator(text);
@@ -120,7 +120,7 @@ private static String removeTrailingSlashes(final String text) {
}
private static String removeLeadingSlashes(final String text) {
- if (text.length() == 0) {
+ if (text.isEmpty()) {
return text;
}
final CharacterIterator it = new StringCharacterIterator(text);
Please sign in to comment.
Something went wrong with that request. Please try again.