Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
provide workaround for Apache adding a "-gzip" to every outgoing etag #…
Browse files Browse the repository at this point in the history
  • Loading branch information
ahus1 committed Nov 4, 2017
1 parent 238dd97 commit 1d3de3c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.dukecon

import flex.messaging.MessageBroker
import flex.messaging.io.SerializationContext
import org.dukecon.server.core.MyShallowEtagHeaderFilter
import org.dukecon.server.repositories.DataProviderLoader
import org.dukecon.server.conference.ConferencesConfigurationServiceImpl
import org.flywaydb.core.Flyway
Expand Down Expand Up @@ -43,7 +44,7 @@ class DukeConServerApplication {

@Bean
Filter shallowEtagHeaderFilter() {
return new ShallowEtagHeaderFilter()
return new MyShallowEtagHeaderFilter()
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.dukecon.server.core;

import org.springframework.web.filter.ShallowEtagHeaderFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
* The Apache web server we run in front of this application compresses the responses with gzip. It also modifies the etag.
* This is a workaround to strip the additional etag from the header when the clients sends a request for this resource.
*
* @author Alexander Schwartz 2017
*/
public class MyShallowEtagHeaderFilter extends ShallowEtagHeaderFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request) {
@Override
public String getHeader(String name) {
String value = super.getHeader(name);
if (name.equalsIgnoreCase("If-None-Match") && value != null) {
value = value.replaceAll("-gzip", "");
}
return value;
}
};
super.doFilterInternal(wrapper, response, filterChain);
}
}

0 comments on commit 1d3de3c

Please sign in to comment.