Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jetty-hpack/pom.xml5
-rw-r--r--jetty-hpack/src/main/java/org/eclipse/jetty/hpack/Field.java74
-rw-r--r--jetty-hpack/src/main/java/org/eclipse/jetty/hpack/HeaderTable.java91
-rw-r--r--jetty-hpack/src/test/java/org/eclipse/jetty/hpack/HpackDecoder.java49
-rw-r--r--jetty-hpack/src/test/java/org/eclipse/jetty/hpack/HpackEncoder.java44
5 files changed, 263 insertions, 0 deletions
diff --git a/jetty-hpack/pom.xml b/jetty-hpack/pom.xml
index 8ff117c22a..ac68f3b1ed 100644
--- a/jetty-hpack/pom.xml
+++ b/jetty-hpack/pom.xml
@@ -24,6 +24,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-io</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
<scope>test</scope>
diff --git a/jetty-hpack/src/main/java/org/eclipse/jetty/hpack/Field.java b/jetty-hpack/src/main/java/org/eclipse/jetty/hpack/Field.java
new file mode 100644
index 0000000000..6c0cd5b180
--- /dev/null
+++ b/jetty-hpack/src/main/java/org/eclipse/jetty/hpack/Field.java
@@ -0,0 +1,74 @@
+//
+// ========================================================================
+// 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.
+// ========================================================================
+//
+
+
+package org.eclipse.jetty.hpack;
+
+import org.eclipse.jetty.http.HttpField;
+import org.eclipse.jetty.http.HttpHeader;
+
+/* ------------------------------------------------------------ */
+/**
+ */
+public class Field extends HttpField
+{
+ // final ByteBuffer _nameLiteral;
+ // final ByteBuffer _nameHuffman;
+
+ public Field(String name,String value)
+ {
+ super(HttpHeader.CACHE.get(name),name,value);
+
+ // Generate a non huffman literal field
+ /*
+ _nameLiteral=BufferUtil.allocate(1+NBitInteger.octectsNeeded(7,name.length())+name.length());
+ BufferUtil.flipToFill(_nameLiteral);
+ _nameLiteral.put((byte)0x00);
+ NBitInteger.encode(_nameLiteral,7,name.length());
+ for (int i=0;i<name.length();i++)
+ {
+ char c=name.charAt(0);
+ if (c<32||c>126)
+ throw new IllegalArgumentException();
+ _nameLiteral.array()[_nameLiteral.position()+i]=(byte)c;
+ }
+ _nameLiteral.position(_nameLiteral.limit());
+ BufferUtil.flipToFlush(_nameLiteral,0);
+
+ // Generate a huffman literal field
+ int h=Huffman.octetsNeeded(name);
+ _nameHuffman=BufferUtil.allocate(1+NBitInteger.octectsNeeded(7,h)+h);
+ BufferUtil.flipToFill(_nameHuffman);
+ _nameHuffman.put((byte)0x80);
+ NBitInteger.encode(_nameHuffman,7,name.length());
+ for (int i=0;i<name.length();i++)
+ {
+ char c=name.charAt(0);
+ if (c<32||c>126)
+ throw new IllegalArgumentException();
+ _nameHuffman.array()[_nameHuffman.position()+i]=(byte)c;
+ }
+ _nameHuffman.position(_nameHuffman.limit());
+ BufferUtil.flipToFlush(_nameHuffman,0);
+ */
+
+ }
+}
+
+
+
diff --git a/jetty-hpack/src/main/java/org/eclipse/jetty/hpack/HeaderTable.java b/jetty-hpack/src/main/java/org/eclipse/jetty/hpack/HeaderTable.java
new file mode 100644
index 0000000000..e7c368d193
--- /dev/null
+++ b/jetty-hpack/src/main/java/org/eclipse/jetty/hpack/HeaderTable.java
@@ -0,0 +1,91 @@
+//
+// ========================================================================
+// 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.
+// ========================================================================
+//
+
+package org.eclipse.jetty.hpack;
+
+public class HeaderTable
+{
+
+ private static final String[][] STATIC_TABLE =
+ {
+ {null,null},
+ /* 1 */ {":authority" ,""},
+ /* 2 */ {":method" ,"GET"},
+ /* 3 */ {":method" ,"POST"},
+ /* 4 */ {":path" ,"/"},
+ /* 5 */ {":path" ,"/index.html"},
+ /* 6 */ {":scheme" ,"http"},
+ /* 7 */ {":scheme" ,"https"},
+ /* 8 */ {":status" ,"200"},
+ /* 9 */ {":status" ,"204"},
+ /* 10 */ {":status" ,"206"},
+ /* 11 */ {":status" ,"304"},
+ /* 12 */ {":status" ,"400"},
+ /* 13 */ {":status" ,"404"},
+ /* 14 */ {":status" ,"500"},
+ /* 15 */ {"accept-charset" ,""},
+ /* 16 */ {"accept-encoding" ,""},
+ /* 17 */ {"accept-language" ,""},
+ /* 18 */ {"accept-ranges" ,""},
+ /* 19 */ {"accept" ,""},
+ /* 20 */ {"access-control-allow-origin" ,""},
+ /* 21 */ {"age" ,""},
+ /* 22 */ {"allow" ,""},
+ /* 23 */ {"authorization" ,""},
+ /* 24 */ {"cache-control" ,""},
+ /* 25 */ {"content-disposition" ,""},
+ /* 26 */ {"content-encoding" ,""},
+ /* 27 */ {"content-language" ,""},
+ /* 28 */ {"content-length" ,""},
+ /* 29 */ {"content-location" ,""},
+ /* 30 */ {"content-range" ,""},
+ /* 31 */ {"content-type" ,""},
+ /* 32 */ {"cookie" ,""},
+ /* 33 */ {"date" ,""},
+ /* 34 */ {"etag" ,""},
+ /* 35 */ {"expect" ,""},
+ /* 36 */ {"expires" ,""},
+ /* 37 */ {"from" ,""},
+ /* 38 */ {"host" ,""},
+ /* 39 */ {"if-match" ,""},
+ /* 40 */ {"if-modified-since" ,""},
+ /* 41 */ {"if-none-match" ,""},
+ /* 42 */ {"if-range" ,""},
+ /* 43 */ {"if-unmodified-since" ,""},
+ /* 44 */ {"last-modified" ,""},
+ /* 45 */ {"link" ,""},
+ /* 46 */ {"location" ,""},
+ /* 47 */ {"max-forwards" ,""},
+ /* 48 */ {"proxy-authenticate" ,""},
+ /* 49 */ {"proxy-authorization" ,""},
+ /* 50 */ {"range" ,""},
+ /* 51 */ {"referer" ,""},
+ /* 52 */ {"refresh" ,""},
+ /* 53 */ {"retry-after" ,""},
+ /* 54 */ {"server" ,""},
+ /* 55 */ {"set-cookie" ,""},
+ /* 56 */ {"strict-transport-security" ,""},
+ /* 57 */ {"transfer-encoding" ,""},
+ /* 58 */ {"user-agent" ,""},
+ /* 59 */ {"vary" ,""},
+ /* 60 */ {"via" ,""},
+ /* 61 */ {"www-authenticate" ,""},
+
+ };
+
+}
diff --git a/jetty-hpack/src/test/java/org/eclipse/jetty/hpack/HpackDecoder.java b/jetty-hpack/src/test/java/org/eclipse/jetty/hpack/HpackDecoder.java
new file mode 100644
index 0000000000..cd2fe30830
--- /dev/null
+++ b/jetty-hpack/src/test/java/org/eclipse/jetty/hpack/HpackDecoder.java
@@ -0,0 +1,49 @@
+//
+// ========================================================================
+// 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.
+// ========================================================================
+//
+
+
+package org.eclipse.jetty.hpack;
+
+import java.nio.ByteBuffer;
+
+import org.eclipse.jetty.http.HttpField;
+
+
+/* ------------------------------------------------------------ */
+/**
+ * This is not thread safe. May only be called by 1 thread at a time
+ */
+public class HpackDecoder
+{
+ public interface Listener
+ {
+ void emit(HttpField field);
+ void endHeaders();
+ }
+
+ public HpackDecoder(Listener listenr)
+ {
+
+ }
+
+ public void parse(ByteBuffer buffer)
+ {
+
+ }
+
+}
diff --git a/jetty-hpack/src/test/java/org/eclipse/jetty/hpack/HpackEncoder.java b/jetty-hpack/src/test/java/org/eclipse/jetty/hpack/HpackEncoder.java
new file mode 100644
index 0000000000..e8a7517138
--- /dev/null
+++ b/jetty-hpack/src/test/java/org/eclipse/jetty/hpack/HpackEncoder.java
@@ -0,0 +1,44 @@
+//
+// ========================================================================
+// 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.
+// ========================================================================
+//
+
+
+package org.eclipse.jetty.hpack;
+
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.io.ByteBufferPool;
+
+
+/* ------------------------------------------------------------ */
+/**
+ */
+public class HpackEncoder
+{
+ public HpackEncoder(ByteBufferPool pool)
+ {
+
+ }
+
+ public List<ByteBuffer> encode(HttpFields fields)
+ {
+ return Collections.emptyList();
+ }
+}

Back to the top