Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2014-12-03 09:36:14 -0500
committerGreg Wilkins2014-12-03 09:36:14 -0500
commit65c7b621f62ee1ecae27739f5fbf1df235bb676b (patch)
tree4a525437a28a62648dbd9f03d4b1ccdabf38e8e8
parente30a8705d8e5f78daead3b0769d5acbe9b3c2bf6 (diff)
downloadorg.eclipse.jetty.project-65c7b621f62ee1ecae27739f5fbf1df235bb676b.tar.gz
org.eclipse.jetty.project-65c7b621f62ee1ecae27739f5fbf1df235bb676b.tar.xz
org.eclipse.jetty.project-65c7b621f62ee1ecae27739f5fbf1df235bb676b.zip
453829 removed code with yahoo copyright
-rw-r--r--jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/HeaderRegexRule.java129
-rw-r--r--jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/HeaderRegexRuleTest.java131
2 files changed, 0 insertions, 260 deletions
diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/HeaderRegexRule.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/HeaderRegexRule.java
deleted file mode 100644
index 4df357452f..0000000000
--- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/HeaderRegexRule.java
+++ /dev/null
@@ -1,129 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-/* Some portions of this code are Copyright (c) 2014, Yahoo! Inc. All rights reserved. */
-
-package org.eclipse.jetty.rewrite.handler;
-
-import java.io.IOException;
-import java.util.regex.Matcher;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-
-/* ------------------------------------------------------------ */
-/** Rule to add a header based on a Regex match
- */
-public class HeaderRegexRule extends RegexRule
-{
-
- private String _name;
- private String _value;
- private boolean _add=false;
-
- /* ------------------------------------------------------------ */
- public HeaderRegexRule()
- {
- _handling = false;
- _terminating = false;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Sets the header name.
- *
- * @param name name of the header field
- */
- public void setName(String name)
- {
- _name = name;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Sets the header value. The value can be either a <code>String</code> or <code>int</code> value.
- *
- * @param value of the header field
- */
- public void setValue(String value)
- {
- _value = value;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Sets the Add flag.
- * @param add If true, the header is added to the response, otherwise the header it is set on the response.
- */
- public void setAdd(boolean add)
- {
- _add = add;
- }
-
- /* ------------------------------------------------------------ */
- @Override
- protected String apply(String target, HttpServletRequest request, HttpServletResponse response, Matcher matcher)
- throws IOException
- {
- // process header
- if (_add)
- response.addHeader(_name, _value);
- else
- response.setHeader(_name, _value);
- return target;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Returns the header name.
- * @return the header name.
- */
- public String getName()
- {
- return _name;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Returns the header value.
- * @return the header value.
- */
- public String getValue()
- {
- return _value;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Returns the add flag value.
- */
- public boolean isAdd()
- {
- return _add;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Returns the header contents.
- */
- @Override
- public String toString()
- {
- return super.toString()+"["+_name+","+_value+"]";
- }
-}
diff --git a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/HeaderRegexRuleTest.java b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/HeaderRegexRuleTest.java
deleted file mode 100644
index 368b561ec0..0000000000
--- a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/HeaderRegexRuleTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-/* Some portions of this code are Copyright (c) 2014, Yahoo! Inc. All rights reserved. */
-package org.eclipse.jetty.rewrite.handler;
-
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-public class HeaderRegexRuleTest extends AbstractRuleTestCase
-{
-
- private HeaderRegexRule _rule;
-
- @Before
- public void init() throws Exception
- {
- start(false);
- _rule = new HeaderRegexRule();
- _rule.setRegex("\\*");
- }
-
- @Test
- public void testHeaderWithTextValues() throws IOException
- {
- // different keys
- String headers[][] =
- {
- { "hnum#1", "test1" },
- { "hnum#2", "2test2" },
- { "hnum#3", "test3" } };
- assertHeaders(headers);
- }
-
- @Test
- public void testHeaderWithNumberValues() throws IOException
- {
- String headers[][] =
- {
- { "hello", "1" },
- { "hello", "-1" },
- { "hello", "100" },
- { "hello", "100" },
- { "hello", "100" },
- { "hello", "100" },
- { "hello", "100" },
- { "hello1", "200" } };
- assertHeaders(headers);
- }
-
- @Test
- public void testHeaderOverwriteValues() throws IOException
- {
- String headers[][] =
- {
- { "size", "100" },
- { "size", "200" },
- { "size", "300" },
- { "size", "400" },
- { "size", "500" },
- { "title", "abc" },
- { "title", "bac" },
- { "title", "cba" },
- { "title1", "abba" },
- { "title1", "abba1" },
- { "title1", "abba" },
- { "title1", "abba1" } };
- assertHeaders(headers);
- Iterator<String> e = _response.getHeaders("size").iterator();
- int count = 0;
- while (e.hasNext())
- {
- e.next();
- count++;
- }
- assertEquals(1,count);
- assertEquals("500",_response.getHeader("size"));
- assertEquals("cba",_response.getHeader("title"));
- assertEquals("abba1",_response.getHeader("title1"));
- }
-
- @Test
- public void testMatch() throws Exception
- {
- _rule.setRegex("/my/dir/file/(.*)$");
- _rule.setName("cache-control");
- _rule.setValue("no-store");
- _rule.matchAndApply("/my/dir/file/",_request,_response);
- assertEquals("no-store",_response.getHeader("cache-control"));
- }
-
- @Test
- public void testNotMatch() throws Exception
- {
- reset();
- _rule.setRegex("/my/dir/file/(.*)$");
- _rule.setName("cache-control");
- _rule.setValue("no-store");
- _rule.matchAndApply("/my/dir/file_not_match/",_request,_response);
- assertEquals(null,_response.getHeader("cache-control"));
- }
-
- private void assertHeaders(String headers[][]) throws IOException
- {
- for (String[] header : headers)
- {
- _rule.setName(header[0]);
- _rule.setValue(header[1]);
- _rule.apply(null,_request,_response,null);
- assertEquals(header[1],_response.getHeader(header[0]));
- }
- }
-}

Back to the top