Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add X-Forward-HTTP-Method-Override -> X-HTTP-Method-Override conversi…

…on, and some java.util.logging (turned OFF)
  • Loading branch information...
commit 28992555ee3571ad28db7cabce3be8700e47df79 1 parent 854223f
@msgilligan authored
View
2  AjaxProxyGrailsPlugin.groovy
@@ -1,5 +1,5 @@
class AjaxProxyGrailsPlugin {
- def version = "0.1.1"
+ def version = "0.1.2"
def grailsVersion = "1.3 > *"
def author = "Sean Gilligan"
View
2  application.properties
@@ -1,2 +1,4 @@
+#Grails Metadata file
+#Sat Jan 21 16:13:50 PST 2012
app.grails.version=2.0.0
plugins.svn=1.0.1
View
18 src/java/net/edwardstx/ProxyServlet.java
@@ -9,6 +9,8 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.Map;
import javax.servlet.ServletConfig;
@@ -39,6 +41,13 @@
* Serialization UID.
*/
private static final long serialVersionUID = 1L;
+
+
+ /**
+ * Logger (use java.util to avoid dependencies - or should we use log4j because of Grails?).
+ */
+ private static Logger logger = Logger.getLogger(ProxyServlet.class.getName());
+
/**
* Key for redirect location header.
*/
@@ -88,6 +97,8 @@
* @param servletConfig The Servlet configuration passed in by the servlet conatiner
*/
public void init(ServletConfig servletConfig) {
+ logger.setLevel(Level.OFF);
+ logger.info("init");
// Get the proxy scheme (http:// or https://)
String stringProxySchemeNew = servletConfig.getInitParameter("proxyScheme");
if(stringProxySchemeNew == null || stringProxySchemeNew.length() == 0 ||
@@ -128,6 +139,7 @@ public void init(ServletConfig servletConfig) {
*/
public void doGet (HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws IOException, ServletException {
+ logger.info("doGet");
// Create a GET request
GetMethod getMethodProxyRequest = new GetMethod(this.getProxyURL(httpServletRequest));
// Forward the request headers
@@ -146,6 +158,7 @@ public void doGet (HttpServletRequest httpServletRequest, HttpServletResponse ht
*/
public void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws IOException, ServletException {
+ logger.info("doPost");
// Create a standard POST request
PostMethod postMethodProxyRequest = new PostMethod(this.getProxyURL(httpServletRequest));
// Forward the request headers
@@ -355,13 +368,18 @@ private void setProxyRequestHeaders(HttpServletRequest httpServletRequest, HttpM
Enumeration enumerationOfHeaderValues = httpServletRequest.getHeaders(stringHeaderName);
while(enumerationOfHeaderValues.hasMoreElements()) {
String stringHeaderValue = (String) enumerationOfHeaderValues.nextElement();
+ logger.info("<== Received request header " + stringHeaderName + " ==: " + stringHeaderValue);
// In case the proxy host is running multiple virtual servers,
// rewrite the Host header to ensure that we get content from
// the correct virtual server
if(stringHeaderName.equalsIgnoreCase(STRING_HOST_HEADER_NAME)){
stringHeaderValue = getProxyHostAndPort();
}
+ if(stringHeaderName.equalsIgnoreCase("X-Forward-HTTP-Method-Override")) {
+ stringHeaderName = "X-HTTP-Method-Override";
+ }
Header header = new Header(stringHeaderName, stringHeaderValue);
+ logger.info("==> Forwarding request header " + stringHeaderName + " ==: " + stringHeaderValue);
// Set the same header on the proxy request
httpMethodProxyRequest.setRequestHeader(header);
}
Please sign in to comment.
Something went wrong with that request. Please try again.