Refactor RequestUtil into a separate package

Move RequestUtil into its own package. This facilitates
reuse of request attribute accessor methods by external
libraries.

Change-Id: Id002eb4f72827d65087a999adbd2ba9a58795fe2
diff --git a/gerrit-httpd/BUCK b/gerrit-httpd/BUCK
index 4ecc9e0..97d28f0 100644
--- a/gerrit-httpd/BUCK
+++ b/gerrit-httpd/BUCK
@@ -18,6 +18,7 @@
     '//gerrit-reviewdb:server',
     '//gerrit-server:server',
     '//gerrit-util-cli:cli',
+    '//gerrit-util-http:http',
     '//lib:args4j',
     '//lib:gson',
     '//lib:guava',
@@ -53,6 +54,7 @@
     '//gerrit-extension-api:api',
     '//gerrit-reviewdb:server',
     '//gerrit-server:server',
+    '//gerrit-util-http:http',
     '//lib:junit',
     '//lib:gson',
     '//lib:gwtorm',
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java
index 44cd84e..f5c6c0c 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java
@@ -26,7 +26,6 @@
 import com.google.common.collect.Maps;
 import com.google.common.net.HttpHeaders;
 import com.google.gerrit.extensions.registration.RegistrationHandle;
-import com.google.gerrit.httpd.RequestUtil;
 import com.google.gerrit.httpd.resources.Resource;
 import com.google.gerrit.httpd.resources.ResourceKey;
 import com.google.gerrit.httpd.resources.SmallResource;
@@ -42,6 +41,7 @@
 import com.google.gerrit.server.plugins.ReloadPluginListener;
 import com.google.gerrit.server.plugins.StartPluginListener;
 import com.google.gerrit.server.ssh.SshInfo;
+import com.google.gerrit.util.http.RequestUtil;
 import com.google.gwtexpui.server.CacheHeaders;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/RestApiServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
index 817ba7e..785b9d4 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
@@ -74,7 +74,6 @@
 import com.google.gerrit.extensions.restapi.RestView;
 import com.google.gerrit.extensions.restapi.TopLevelResource;
 import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
-import com.google.gerrit.httpd.RequestUtil;
 import com.google.gerrit.httpd.WebSession;
 import com.google.gerrit.server.AccessPath;
 import com.google.gerrit.server.AnonymousUser;
@@ -82,6 +81,7 @@
 import com.google.gerrit.server.OptionUtil;
 import com.google.gerrit.server.OutputFormat;
 import com.google.gerrit.server.account.CapabilityUtils;
+import com.google.gerrit.util.http.RequestUtil;
 import com.google.gson.ExclusionStrategy;
 import com.google.gson.FieldAttributes;
 import com.google.gson.FieldNamingPolicy;
diff --git a/gerrit-util-http/BUCK b/gerrit-util-http/BUCK
new file mode 100644
index 0000000..7041c0a
--- /dev/null
+++ b/gerrit-util-http/BUCK
@@ -0,0 +1,20 @@
+java_library(
+  name = 'http',
+  srcs = glob(['src/main/java/**/*.java']),
+  provided_deps = ['//lib:servlet-api-3_1'],
+  visibility = ['PUBLIC'],
+)
+
+java_test(
+  name = 'http_tests',
+  srcs = glob(['src/test/java/**/*.java']),
+  deps = [
+    ':http',
+    '//lib:junit',
+    '//lib:servlet-api-3_1',
+    '//lib/easymock:easymock',
+  ],
+  source_under_test = [':http'],
+  # TODO(sop) Remove after Buck supports Eclipse
+  visibility = ['//tools/eclipse:classpath'],
+)
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/RequestUtil.java b/gerrit-util-http/src/main/java/com/google/gerrit/util/http/RequestUtil.java
similarity index 97%
rename from gerrit-httpd/src/main/java/com/google/gerrit/httpd/RequestUtil.java
rename to gerrit-util-http/src/main/java/com/google/gerrit/util/http/RequestUtil.java
index 04aa44a..922a8d5 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/RequestUtil.java
+++ b/gerrit-util-http/src/main/java/com/google/gerrit/util/http/RequestUtil.java
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package com.google.gerrit.httpd;
+package com.google.gerrit.util.http;
 
 import javax.servlet.http.HttpServletRequest;
 
diff --git a/gerrit-httpd/src/test/java/com/google/gerrit/httpd/RequestUtilTest.java b/gerrit-util-http/src/test/java/com/google/gerrit/util/http/RequestUtilTest.java
similarity index 98%
rename from gerrit-httpd/src/test/java/com/google/gerrit/httpd/RequestUtilTest.java
rename to gerrit-util-http/src/test/java/com/google/gerrit/util/http/RequestUtilTest.java
index 71a43bf..cfa0111 100644
--- a/gerrit-httpd/src/test/java/com/google/gerrit/httpd/RequestUtilTest.java
+++ b/gerrit-util-http/src/test/java/com/google/gerrit/util/http/RequestUtilTest.java
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package com.google.gerrit.httpd;
+package com.google.gerrit.util.http;
 
 import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.expect;