Fix parameter namings + some more
This commit is contained in:
parent
6f2840193a
commit
36c8eb02e8
@ -999,8 +999,8 @@ public class HttpHeaders {
|
|||||||
return hash % BUCKET_SIZE;
|
return hash % BUCKET_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Entry[] entries = new Entry[BUCKET_SIZE];
|
private final HeaderEntry[] entries = new HeaderEntry[BUCKET_SIZE];
|
||||||
private final Entry head = new Entry(-1, null, null);
|
private final HeaderEntry head = new HeaderEntry(-1, null, null);
|
||||||
|
|
||||||
HttpHeaders() {
|
HttpHeaders() {
|
||||||
head.before = head.after = head;
|
head.before = head.after = head;
|
||||||
@ -1021,9 +1021,9 @@ public class HttpHeaders {
|
|||||||
|
|
||||||
private void addHeader0(int h, int i, final String name, final String value) {
|
private void addHeader0(int h, int i, final String name, final String value) {
|
||||||
// Update the hash table.
|
// Update the hash table.
|
||||||
Entry e = entries[i];
|
HeaderEntry e = entries[i];
|
||||||
Entry newEntry;
|
HeaderEntry newEntry;
|
||||||
entries[i] = newEntry = new Entry(h, name, value);
|
entries[i] = newEntry = new HeaderEntry(h, name, value);
|
||||||
newEntry.next = e;
|
newEntry.next = e;
|
||||||
|
|
||||||
// Update the linked list.
|
// Update the linked list.
|
||||||
@ -1040,7 +1040,7 @@ public class HttpHeaders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeHeader0(int h, int i, String name) {
|
private void removeHeader0(int h, int i, String name) {
|
||||||
Entry e = entries[i];
|
HeaderEntry e = entries[i];
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1048,7 +1048,7 @@ public class HttpHeaders {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
if (e.hash == h && eq(name, e.key)) {
|
if (e.hash == h && eq(name, e.key)) {
|
||||||
e.remove();
|
e.remove();
|
||||||
Entry next = e.next;
|
HeaderEntry next = e.next;
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
entries[i] = next;
|
entries[i] = next;
|
||||||
e = next;
|
e = next;
|
||||||
@ -1062,7 +1062,7 @@ public class HttpHeaders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
Entry next = e.next;
|
HeaderEntry next = e.next;
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1120,7 +1120,7 @@ public class HttpHeaders {
|
|||||||
|
|
||||||
int h = hash(name);
|
int h = hash(name);
|
||||||
int i = index(h);
|
int i = index(h);
|
||||||
Entry e = entries[i];
|
HeaderEntry e = entries[i];
|
||||||
while (e != null) {
|
while (e != null) {
|
||||||
if (e.hash == h && eq(name, e.key)) {
|
if (e.hash == h && eq(name, e.key)) {
|
||||||
return e.value;
|
return e.value;
|
||||||
@ -1140,7 +1140,7 @@ public class HttpHeaders {
|
|||||||
|
|
||||||
int h = hash(name);
|
int h = hash(name);
|
||||||
int i = index(h);
|
int i = index(h);
|
||||||
Entry e = entries[i];
|
HeaderEntry e = entries[i];
|
||||||
while (e != null) {
|
while (e != null) {
|
||||||
if (e.hash == h && eq(name, e.key)) {
|
if (e.hash == h && eq(name, e.key)) {
|
||||||
values.addFirst(e.value);
|
values.addFirst(e.value);
|
||||||
@ -1154,7 +1154,7 @@ public class HttpHeaders {
|
|||||||
List<Map.Entry<String, String>> all =
|
List<Map.Entry<String, String>> all =
|
||||||
new LinkedList<Map.Entry<String, String>>();
|
new LinkedList<Map.Entry<String, String>>();
|
||||||
|
|
||||||
Entry e = head.after;
|
HeaderEntry e = head.after;
|
||||||
while (e != head) {
|
while (e != head) {
|
||||||
all.add(e);
|
all.add(e);
|
||||||
e = e.after;
|
e = e.after;
|
||||||
@ -1170,7 +1170,7 @@ public class HttpHeaders {
|
|||||||
|
|
||||||
Set<String> names = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
Set<String> names = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
Entry e = head.after;
|
HeaderEntry e = head.after;
|
||||||
while (e != head) {
|
while (e != head) {
|
||||||
names.add(e.key);
|
names.add(e.key);
|
||||||
e = e.after;
|
e = e.after;
|
||||||
@ -1197,14 +1197,14 @@ public class HttpHeaders {
|
|||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class Entry implements Map.Entry<String, String> {
|
private static final class HeaderEntry implements Map.Entry<String, String> {
|
||||||
final int hash;
|
final int hash;
|
||||||
final String key;
|
final String key;
|
||||||
String value;
|
String value;
|
||||||
Entry next;
|
HeaderEntry next;
|
||||||
Entry before, after;
|
HeaderEntry before, after;
|
||||||
|
|
||||||
Entry(int hash, String key, String value) {
|
HeaderEntry(int hash, String key, String value) {
|
||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@ -1215,7 +1215,7 @@ public class HttpHeaders {
|
|||||||
after.before = before;
|
after.before = before;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addBefore(Entry e) {
|
void addBefore(HeaderEntry e) {
|
||||||
after = e;
|
after = e;
|
||||||
before = e.before;
|
before = e.before;
|
||||||
before.after = this;
|
before.after = this;
|
||||||
|
@ -93,12 +93,12 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(InterfaceHttpData arg0) {
|
public int compareTo(InterfaceHttpData o) {
|
||||||
if (!(arg0 instanceof Attribute)) {
|
if (!(o instanceof Attribute)) {
|
||||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||||
" with " + arg0.getHttpDataType());
|
" with " + o.getHttpDataType());
|
||||||
}
|
}
|
||||||
return compareTo((Attribute) arg0);
|
return compareTo((Attribute) o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(Attribute o) {
|
public int compareTo(Attribute o) {
|
||||||
|
@ -79,12 +79,12 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(InterfaceHttpData arg0) {
|
public int compareTo(InterfaceHttpData o) {
|
||||||
if (!(arg0 instanceof FileUpload)) {
|
if (!(o instanceof FileUpload)) {
|
||||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||||
" with " + arg0.getHttpDataType());
|
" with " + o.getHttpDataType());
|
||||||
}
|
}
|
||||||
return compareTo((FileUpload) arg0);
|
return compareTo((FileUpload) o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(FileUpload o) {
|
public int compareTo(FileUpload o) {
|
||||||
|
@ -2034,16 +2034,16 @@ public class HttpPostRequestDecoder {
|
|||||||
public ErrorDataDecoderException() {
|
public ErrorDataDecoderException() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ErrorDataDecoderException(String arg0) {
|
public ErrorDataDecoderException(String msg) {
|
||||||
super(arg0);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ErrorDataDecoderException(Throwable arg0) {
|
public ErrorDataDecoderException(Throwable cause) {
|
||||||
super(arg0);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ErrorDataDecoderException(String arg0, Throwable arg1) {
|
public ErrorDataDecoderException(String msg, Throwable cause) {
|
||||||
super(arg0, arg1);
|
super(msg, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,12 +70,12 @@ public class InternalAttribute implements InterfaceHttpData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(InterfaceHttpData arg0) {
|
public int compareTo(InterfaceHttpData o) {
|
||||||
if (!(arg0 instanceof InternalAttribute)) {
|
if (!(o instanceof InternalAttribute)) {
|
||||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||||
" with " + arg0.getHttpDataType());
|
" with " + o.getHttpDataType());
|
||||||
}
|
}
|
||||||
return compareTo((InternalAttribute) arg0);
|
return compareTo((InternalAttribute) o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(InternalAttribute o) {
|
public int compareTo(InternalAttribute o) {
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.handler.codec.http.multipart;
|
package io.netty.handler.codec.http.multipart;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
import io.netty.handler.codec.http.HttpHeaders;
|
import io.netty.handler.codec.http.HttpHeaders;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default FileUpload implementation that stores file into memory.<br><br>
|
* Default FileUpload implementation that stores file into memory.<br><br>
|
||||||
*
|
*
|
||||||
@ -73,12 +73,12 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(InterfaceHttpData arg0) {
|
public int compareTo(InterfaceHttpData o) {
|
||||||
if (!(arg0 instanceof FileUpload)) {
|
if (!(o instanceof FileUpload)) {
|
||||||
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
throw new ClassCastException("Cannot compare " + getHttpDataType() +
|
||||||
" with " + arg0.getHttpDataType());
|
" with " + o.getHttpDataType());
|
||||||
}
|
}
|
||||||
return compareTo((FileUpload) arg0);
|
return compareTo((FileUpload) o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(FileUpload o) {
|
public int compareTo(FileUpload o) {
|
||||||
|
@ -35,14 +35,14 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSet(int ID) {
|
public boolean isSet(int id) {
|
||||||
Integer key = new Integer(ID);
|
Integer key = Integer.valueOf(id);
|
||||||
return settingsMap.containsKey(key);
|
return settingsMap.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getValue(int ID) {
|
public int getValue(int id) {
|
||||||
Integer key = new Integer(ID);
|
Integer key = Integer.valueOf(id);
|
||||||
if (settingsMap.containsKey(key)) {
|
if (settingsMap.containsKey(key)) {
|
||||||
return settingsMap.get(key).getValue();
|
return settingsMap.get(key).getValue();
|
||||||
} else {
|
} else {
|
||||||
@ -51,16 +51,16 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(int ID, int value) {
|
public void setValue(int id, int value) {
|
||||||
setValue(ID, value, false, false);
|
setValue(id, value, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(int ID, int value, boolean persistValue, boolean persisted) {
|
public void setValue(int id, int value, boolean persistValue, boolean persisted) {
|
||||||
if (ID <= 0 || ID > SpdyCodecUtil.SPDY_SETTINGS_MAX_ID) {
|
if (id <= 0 || id > SpdyCodecUtil.SPDY_SETTINGS_MAX_ID) {
|
||||||
throw new IllegalArgumentException("Setting ID is not valid: " + ID);
|
throw new IllegalArgumentException("Setting ID is not valid: " + id);
|
||||||
}
|
}
|
||||||
Integer key = new Integer(ID);
|
Integer key = Integer.valueOf(id);
|
||||||
if (settingsMap.containsKey(key)) {
|
if (settingsMap.containsKey(key)) {
|
||||||
Setting setting = settingsMap.get(key);
|
Setting setting = settingsMap.get(key);
|
||||||
setting.setValue(value);
|
setting.setValue(value);
|
||||||
@ -72,16 +72,16 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeValue(int ID) {
|
public void removeValue(int id) {
|
||||||
Integer key = new Integer(ID);
|
Integer key = Integer.valueOf(id);
|
||||||
if (settingsMap.containsKey(key)) {
|
if (settingsMap.containsKey(key)) {
|
||||||
settingsMap.remove(key);
|
settingsMap.remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPersistValue(int ID) {
|
public boolean isPersistValue(int id) {
|
||||||
Integer key = new Integer(ID);
|
Integer key = Integer.valueOf(id);
|
||||||
if (settingsMap.containsKey(key)) {
|
if (settingsMap.containsKey(key)) {
|
||||||
return settingsMap.get(key).isPersist();
|
return settingsMap.get(key).isPersist();
|
||||||
} else {
|
} else {
|
||||||
@ -90,16 +90,16 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPersistValue(int ID, boolean persistValue) {
|
public void setPersistValue(int id, boolean persistValue) {
|
||||||
Integer key = new Integer(ID);
|
Integer key = Integer.valueOf(id);
|
||||||
if (settingsMap.containsKey(key)) {
|
if (settingsMap.containsKey(key)) {
|
||||||
settingsMap.get(key).setPersist(persistValue);
|
settingsMap.get(key).setPersist(persistValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPersisted(int ID) {
|
public boolean isPersisted(int id) {
|
||||||
Integer key = new Integer(ID);
|
Integer key = Integer.valueOf(id);
|
||||||
if (settingsMap.containsKey(key)) {
|
if (settingsMap.containsKey(key)) {
|
||||||
return settingsMap.get(key).isPersisted();
|
return settingsMap.get(key).isPersisted();
|
||||||
} else {
|
} else {
|
||||||
@ -108,8 +108,8 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPersisted(int ID, boolean persisted) {
|
public void setPersisted(int id, boolean persisted) {
|
||||||
Integer key = new Integer(ID);
|
Integer key = Integer.valueOf(id);
|
||||||
if (settingsMap.containsKey(key)) {
|
if (settingsMap.containsKey(key)) {
|
||||||
settingsMap.get(key).setPersisted(persisted);
|
settingsMap.get(key).setPersisted(persisted);
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ final class SpdyCodecUtil {
|
|||||||
try {
|
try {
|
||||||
SPDY2_DICT_ = SPDY2_DICT_S.getBytes(CharsetUtil.US_ASCII);
|
SPDY2_DICT_ = SPDY2_DICT_S.getBytes(CharsetUtil.US_ASCII);
|
||||||
// dictionary is null terminated
|
// dictionary is null terminated
|
||||||
SPDY2_DICT_[SPDY2_DICT_.length - 1] = (byte) 0;
|
SPDY2_DICT_[SPDY2_DICT_.length - 1] = 0;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SPDY2_DICT_ = new byte[1];
|
SPDY2_DICT_ = new byte[1];
|
||||||
}
|
}
|
||||||
@ -307,9 +307,9 @@ final class SpdyCodecUtil {
|
|||||||
/**
|
/**
|
||||||
* Returns {@code true} if ID is for a server initiated stream or ping.
|
* Returns {@code true} if ID is for a server initiated stream or ping.
|
||||||
*/
|
*/
|
||||||
static boolean isServerId(int ID) {
|
static boolean isServerId(int id) {
|
||||||
// Server initiated streams and pings have even IDs
|
// Server initiated streams and pings have even IDs
|
||||||
return ID % 2 == 0;
|
return id % 2 == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -527,8 +527,8 @@ public class SpdyHeaders {
|
|||||||
return hash % BUCKET_SIZE;
|
return hash % BUCKET_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Entry[] entries = new Entry[BUCKET_SIZE];
|
private final HeaderEntry[] entries = new HeaderEntry[BUCKET_SIZE];
|
||||||
private final Entry head = new Entry(-1, null, null);
|
private final HeaderEntry head = new HeaderEntry(-1, null, null);
|
||||||
|
|
||||||
SpdyHeaders() {
|
SpdyHeaders() {
|
||||||
head.before = head.after = head;
|
head.before = head.after = head;
|
||||||
@ -546,9 +546,9 @@ public class SpdyHeaders {
|
|||||||
|
|
||||||
private void addHeader0(int h, int i, final String name, final String value) {
|
private void addHeader0(int h, int i, final String name, final String value) {
|
||||||
// Update the hash table.
|
// Update the hash table.
|
||||||
Entry e = entries[i];
|
HeaderEntry e = entries[i];
|
||||||
Entry newEntry;
|
HeaderEntry newEntry;
|
||||||
entries[i] = newEntry = new Entry(h, name, value);
|
entries[i] = newEntry = new HeaderEntry(h, name, value);
|
||||||
newEntry.next = e;
|
newEntry.next = e;
|
||||||
|
|
||||||
// Update the linked list.
|
// Update the linked list.
|
||||||
@ -566,7 +566,7 @@ public class SpdyHeaders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeHeader0(int h, int i, String name) {
|
private void removeHeader0(int h, int i, String name) {
|
||||||
Entry e = entries[i];
|
HeaderEntry e = entries[i];
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -574,7 +574,7 @@ public class SpdyHeaders {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
if (e.hash == h && eq(name, e.key)) {
|
if (e.hash == h && eq(name, e.key)) {
|
||||||
e.remove();
|
e.remove();
|
||||||
Entry next = e.next;
|
HeaderEntry next = e.next;
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
entries[i] = next;
|
entries[i] = next;
|
||||||
e = next;
|
e = next;
|
||||||
@ -588,7 +588,7 @@ public class SpdyHeaders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
Entry next = e.next;
|
HeaderEntry next = e.next;
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -648,7 +648,7 @@ public class SpdyHeaders {
|
|||||||
|
|
||||||
int h = hash(name);
|
int h = hash(name);
|
||||||
int i = index(h);
|
int i = index(h);
|
||||||
Entry e = entries[i];
|
HeaderEntry e = entries[i];
|
||||||
while (e != null) {
|
while (e != null) {
|
||||||
if (e.hash == h && eq(name, e.key)) {
|
if (e.hash == h && eq(name, e.key)) {
|
||||||
return e.value;
|
return e.value;
|
||||||
@ -668,7 +668,7 @@ public class SpdyHeaders {
|
|||||||
|
|
||||||
int h = hash(name);
|
int h = hash(name);
|
||||||
int i = index(h);
|
int i = index(h);
|
||||||
Entry e = entries[i];
|
HeaderEntry e = entries[i];
|
||||||
while (e != null) {
|
while (e != null) {
|
||||||
if (e.hash == h && eq(name, e.key)) {
|
if (e.hash == h && eq(name, e.key)) {
|
||||||
values.addFirst(e.value);
|
values.addFirst(e.value);
|
||||||
@ -682,7 +682,7 @@ public class SpdyHeaders {
|
|||||||
List<Map.Entry<String, String>> all =
|
List<Map.Entry<String, String>> all =
|
||||||
new LinkedList<Map.Entry<String, String>>();
|
new LinkedList<Map.Entry<String, String>>();
|
||||||
|
|
||||||
Entry e = head.after;
|
HeaderEntry e = head.after;
|
||||||
while (e != head) {
|
while (e != head) {
|
||||||
all.add(e);
|
all.add(e);
|
||||||
e = e.after;
|
e = e.after;
|
||||||
@ -697,7 +697,7 @@ public class SpdyHeaders {
|
|||||||
Set<String> getHeaderNames() {
|
Set<String> getHeaderNames() {
|
||||||
Set<String> names = new TreeSet<String>();
|
Set<String> names = new TreeSet<String>();
|
||||||
|
|
||||||
Entry e = head.after;
|
HeaderEntry e = head.after;
|
||||||
while (e != head) {
|
while (e != head) {
|
||||||
names.add(e.key);
|
names.add(e.key);
|
||||||
e = e.after;
|
e = e.after;
|
||||||
@ -712,14 +712,14 @@ public class SpdyHeaders {
|
|||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class Entry implements Map.Entry<String, String> {
|
private static final class HeaderEntry implements Map.Entry<String, String> {
|
||||||
final int hash;
|
final int hash;
|
||||||
final String key;
|
final String key;
|
||||||
String value;
|
String value;
|
||||||
Entry next;
|
HeaderEntry next;
|
||||||
Entry before, after;
|
HeaderEntry before, after;
|
||||||
|
|
||||||
Entry(int hash, String key, String value) {
|
HeaderEntry(int hash, String key, String value) {
|
||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@ -730,7 +730,7 @@ public class SpdyHeaders {
|
|||||||
after.before = before;
|
after.before = before;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addBefore(Entry e) {
|
void addBefore(HeaderEntry e) {
|
||||||
after = e;
|
after = e;
|
||||||
before = e.before;
|
before = e.before;
|
||||||
before.after = this;
|
before.after = this;
|
||||||
|
@ -38,6 +38,7 @@ public class SpdySessionHandler
|
|||||||
private static final SpdyProtocolException STREAM_CLOSED = new SpdyProtocolException("Stream closed");
|
private static final SpdyProtocolException STREAM_CLOSED = new SpdyProtocolException("Stream closed");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@SuppressWarnings("ZeroLengthArrayAllocation")
|
||||||
StackTraceElement[] emptyTrace = new StackTraceElement[0];
|
StackTraceElement[] emptyTrace = new StackTraceElement[0];
|
||||||
PROTOCOL_EXCEPTION.setStackTrace(emptyTrace);
|
PROTOCOL_EXCEPTION.setStackTrace(emptyTrace);
|
||||||
STREAM_CLOSED.setStackTrace(emptyTrace);
|
STREAM_CLOSED.setStackTrace(emptyTrace);
|
||||||
@ -695,8 +696,8 @@ public class SpdySessionHandler
|
|||||||
* Helper functions
|
* Helper functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private boolean isRemoteInitiatedID(int ID) {
|
private boolean isRemoteInitiatedID(int id) {
|
||||||
boolean serverID = SpdyCodecUtil.isServerId(ID);
|
boolean serverID = SpdyCodecUtil.isServerId(id);
|
||||||
return server && !serverID || !server && serverID;
|
return server && !serverID || !server && serverID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,14 +20,12 @@ import io.netty.channel.ChannelInboundMessageHandlerAdapter;
|
|||||||
import io.netty.channel.embedded.EmbeddedMessageChannel;
|
import io.netty.channel.embedded.EmbeddedMessageChannel;
|
||||||
import io.netty.logging.InternalLogger;
|
import io.netty.logging.InternalLogger;
|
||||||
import io.netty.logging.InternalLoggerFactory;
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class SpdySessionHandlerTest {
|
public class SpdySessionHandlerTest {
|
||||||
|
|
||||||
@ -45,25 +43,25 @@ public class SpdySessionHandlerTest {
|
|||||||
for (String name: expected.getHeaderNames()) {
|
for (String name: expected.getHeaderNames()) {
|
||||||
List<String> expectedValues = expected.getHeaders(name);
|
List<String> expectedValues = expected.getHeaders(name);
|
||||||
List<String> receivedValues = received.getHeaders(name);
|
List<String> receivedValues = received.getHeaders(name);
|
||||||
Assert.assertTrue(receivedValues.containsAll(expectedValues));
|
assertTrue(receivedValues.containsAll(expectedValues));
|
||||||
receivedValues.removeAll(expectedValues);
|
receivedValues.removeAll(expectedValues);
|
||||||
Assert.assertTrue(receivedValues.isEmpty());
|
assertTrue(receivedValues.isEmpty());
|
||||||
received.removeHeader(name);
|
received.removeHeader(name);
|
||||||
}
|
}
|
||||||
Assert.assertTrue(received.getHeaders().isEmpty());
|
assertTrue(received.getHeaders().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertDataFrame(Object msg, int streamID, boolean last) {
|
private static void assertDataFrame(Object msg, int streamID, boolean last) {
|
||||||
Assert.assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
Assert.assertTrue(msg instanceof SpdyDataFrame);
|
assertTrue(msg instanceof SpdyDataFrame);
|
||||||
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
|
||||||
assertEquals(spdyDataFrame.getStreamId(), streamID);
|
assertEquals(spdyDataFrame.getStreamId(), streamID);
|
||||||
assertEquals(spdyDataFrame.isLast(), last);
|
assertEquals(spdyDataFrame.isLast(), last);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertSynReply(Object msg, int streamID, boolean last, SpdyHeaderBlock headers) {
|
private static void assertSynReply(Object msg, int streamID, boolean last, SpdyHeaderBlock headers) {
|
||||||
Assert.assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
Assert.assertTrue(msg instanceof SpdySynReplyFrame);
|
assertTrue(msg instanceof SpdySynReplyFrame);
|
||||||
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
|
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
|
||||||
assertEquals(spdySynReplyFrame.getStreamId(), streamID);
|
assertEquals(spdySynReplyFrame.getStreamId(), streamID);
|
||||||
assertEquals(spdySynReplyFrame.isLast(), last);
|
assertEquals(spdySynReplyFrame.isLast(), last);
|
||||||
@ -71,36 +69,36 @@ public class SpdySessionHandlerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void assertRstStream(Object msg, int streamID, SpdyStreamStatus status) {
|
private static void assertRstStream(Object msg, int streamID, SpdyStreamStatus status) {
|
||||||
Assert.assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
Assert.assertTrue(msg instanceof SpdyRstStreamFrame);
|
assertTrue(msg instanceof SpdyRstStreamFrame);
|
||||||
SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg;
|
SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg;
|
||||||
assertEquals(spdyRstStreamFrame.getStreamId(), streamID);
|
assertEquals(spdyRstStreamFrame.getStreamId(), streamID);
|
||||||
assertEquals(spdyRstStreamFrame.getStatus(), status);
|
assertEquals(spdyRstStreamFrame.getStatus(), status);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertPing(Object msg, int ID) {
|
private static void assertPing(Object msg, int id) {
|
||||||
Assert.assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
Assert.assertTrue(msg instanceof SpdyPingFrame);
|
assertTrue(msg instanceof SpdyPingFrame);
|
||||||
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
|
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
|
||||||
assertEquals(spdyPingFrame.getId(), ID);
|
assertEquals(spdyPingFrame.getId(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertGoAway(Object msg, int lastGoodStreamID) {
|
private static void assertGoAway(Object msg, int lastGoodStreamID) {
|
||||||
Assert.assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
Assert.assertTrue(msg instanceof SpdyGoAwayFrame);
|
assertTrue(msg instanceof SpdyGoAwayFrame);
|
||||||
SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg;
|
SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg;
|
||||||
assertEquals(spdyGoAwayFrame.getLastGoodStreamId(), lastGoodStreamID);
|
assertEquals(spdyGoAwayFrame.getLastGoodStreamId(), lastGoodStreamID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertHeaders(Object msg, int streamID, SpdyHeaderBlock headers) {
|
private static void assertHeaders(Object msg, int streamID, SpdyHeaderBlock headers) {
|
||||||
Assert.assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
Assert.assertTrue(msg instanceof SpdyHeadersFrame);
|
assertTrue(msg instanceof SpdyHeadersFrame);
|
||||||
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
|
||||||
assertEquals(spdyHeadersFrame.getStreamId(), streamID);
|
assertEquals(spdyHeadersFrame.getStreamId(), streamID);
|
||||||
assertHeaderBlock(spdyHeadersFrame, headers);
|
assertHeaderBlock(spdyHeadersFrame, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testSpdySessionHandler(int version, boolean server) {
|
private static void testSpdySessionHandler(int version, boolean server) {
|
||||||
EmbeddedMessageChannel sessionHandler = new EmbeddedMessageChannel(
|
EmbeddedMessageChannel sessionHandler = new EmbeddedMessageChannel(
|
||||||
new SpdySessionHandler(version, server), new EchoHandler(closeSignal, server));
|
new SpdySessionHandler(version, server), new EchoHandler(closeSignal, server));
|
||||||
|
|
||||||
@ -125,34 +123,34 @@ public class SpdySessionHandlerTest {
|
|||||||
// a data frame for a Stream-ID that is not open
|
// a data frame for a Stream-ID that is not open
|
||||||
sessionHandler.writeInbound(new DefaultSpdyDataFrame(localStreamID));
|
sessionHandler.writeInbound(new DefaultSpdyDataFrame(localStreamID));
|
||||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.INVALID_STREAM);
|
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.INVALID_STREAM);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
|
|
||||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||||
// a data frame for a Stream-ID before receiving a SYN_REPLY frame
|
// a data frame for a Stream-ID before receiving a SYN_REPLY frame
|
||||||
sessionHandler.writeInbound(new DefaultSpdyDataFrame(remoteStreamID));
|
sessionHandler.writeInbound(new DefaultSpdyDataFrame(remoteStreamID));
|
||||||
assertRstStream(sessionHandler.readOutbound(), remoteStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
assertRstStream(sessionHandler.readOutbound(), remoteStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
remoteStreamID += 2;
|
remoteStreamID += 2;
|
||||||
|
|
||||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||||
// multiple SYN_REPLY frames for the same active Stream-ID
|
// multiple SYN_REPLY frames for the same active Stream-ID
|
||||||
sessionHandler.writeInbound(new DefaultSpdySynReplyFrame(remoteStreamID));
|
sessionHandler.writeInbound(new DefaultSpdySynReplyFrame(remoteStreamID));
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
sessionHandler.writeInbound(new DefaultSpdySynReplyFrame(remoteStreamID));
|
sessionHandler.writeInbound(new DefaultSpdySynReplyFrame(remoteStreamID));
|
||||||
assertRstStream(sessionHandler.readOutbound(), remoteStreamID, SpdyStreamStatus.STREAM_IN_USE);
|
assertRstStream(sessionHandler.readOutbound(), remoteStreamID, SpdyStreamStatus.STREAM_IN_USE);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
remoteStreamID += 2;
|
remoteStreamID += 2;
|
||||||
|
|
||||||
// Check if frame codec correctly compresses/uncompresses headers
|
// Check if frame codec correctly compresses/uncompresses headers
|
||||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||||
assertSynReply(sessionHandler.readOutbound(), localStreamID, false, spdySynStreamFrame);
|
assertSynReply(sessionHandler.readOutbound(), localStreamID, false, spdySynStreamFrame);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(localStreamID);
|
SpdyHeadersFrame spdyHeadersFrame = new DefaultSpdyHeadersFrame(localStreamID);
|
||||||
spdyHeadersFrame.addHeader("HEADER","test1");
|
spdyHeadersFrame.addHeader("HEADER","test1");
|
||||||
spdyHeadersFrame.addHeader("HEADER","test2");
|
spdyHeadersFrame.addHeader("HEADER","test2");
|
||||||
sessionHandler.writeInbound(spdyHeadersFrame);
|
sessionHandler.writeInbound(spdyHeadersFrame);
|
||||||
assertHeaders(sessionHandler.readOutbound(), localStreamID, spdyHeadersFrame);
|
assertHeaders(sessionHandler.readOutbound(), localStreamID, spdyHeadersFrame);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
localStreamID += 2;
|
localStreamID += 2;
|
||||||
|
|
||||||
// Check if session handler closed the streams using the number
|
// Check if session handler closed the streams using the number
|
||||||
@ -163,25 +161,25 @@ public class SpdySessionHandlerTest {
|
|||||||
spdySynStreamFrame.setUnidirectional(true);
|
spdySynStreamFrame.setUnidirectional(true);
|
||||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
|
|
||||||
// Check if session handler drops active streams if it receives
|
// Check if session handler drops active streams if it receives
|
||||||
// a RST_STREAM frame for that Stream-ID
|
// a RST_STREAM frame for that Stream-ID
|
||||||
sessionHandler.writeInbound(new DefaultSpdyRstStreamFrame(remoteStreamID, 3));
|
sessionHandler.writeInbound(new DefaultSpdyRstStreamFrame(remoteStreamID, 3));
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
remoteStreamID += 2;
|
remoteStreamID += 2;
|
||||||
|
|
||||||
// Check if session handler honors UNIDIRECTIONAL streams
|
// Check if session handler honors UNIDIRECTIONAL streams
|
||||||
spdySynStreamFrame.setLast(false);
|
spdySynStreamFrame.setLast(false);
|
||||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
spdySynStreamFrame.setUnidirectional(false);
|
spdySynStreamFrame.setUnidirectional(false);
|
||||||
|
|
||||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||||
// multiple SYN_STREAM frames for the same active Stream-ID
|
// multiple SYN_STREAM frames for the same active Stream-ID
|
||||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
localStreamID += 2;
|
localStreamID += 2;
|
||||||
|
|
||||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||||
@ -189,7 +187,7 @@ public class SpdySessionHandlerTest {
|
|||||||
spdySynStreamFrame.setStreamId(localStreamID - 1);
|
spdySynStreamFrame.setStreamId(localStreamID - 1);
|
||||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||||
assertRstStream(sessionHandler.readOutbound(), localStreamID - 1, SpdyStreamStatus.PROTOCOL_ERROR);
|
assertRstStream(sessionHandler.readOutbound(), localStreamID - 1, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
spdySynStreamFrame.setStreamId(localStreamID);
|
spdySynStreamFrame.setStreamId(localStreamID);
|
||||||
|
|
||||||
// Check if session handler correctly limits the number of
|
// Check if session handler correctly limits the number of
|
||||||
@ -197,26 +195,26 @@ public class SpdySessionHandlerTest {
|
|||||||
SpdySettingsFrame spdySettingsFrame = new DefaultSpdySettingsFrame();
|
SpdySettingsFrame spdySettingsFrame = new DefaultSpdySettingsFrame();
|
||||||
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 2);
|
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 2);
|
||||||
sessionHandler.writeInbound(spdySettingsFrame);
|
sessionHandler.writeInbound(spdySettingsFrame);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 4);
|
spdySettingsFrame.setValue(SpdySettingsFrame.SETTINGS_MAX_CONCURRENT_STREAMS, 4);
|
||||||
sessionHandler.writeInbound(spdySettingsFrame);
|
sessionHandler.writeInbound(spdySettingsFrame);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||||
assertSynReply(sessionHandler.readOutbound(), localStreamID, false, spdySynStreamFrame);
|
assertSynReply(sessionHandler.readOutbound(), localStreamID, false, spdySynStreamFrame);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
|
|
||||||
// Check if session handler rejects HEADERS for closed streams
|
// Check if session handler rejects HEADERS for closed streams
|
||||||
int testStreamID = spdyDataFrame.getStreamId();
|
int testStreamID = spdyDataFrame.getStreamId();
|
||||||
sessionHandler.writeInbound(spdyDataFrame);
|
sessionHandler.writeInbound(spdyDataFrame);
|
||||||
assertDataFrame(sessionHandler.readOutbound(), testStreamID, spdyDataFrame.isLast());
|
assertDataFrame(sessionHandler.readOutbound(), testStreamID, spdyDataFrame.isLast());
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
spdyHeadersFrame.setStreamId(testStreamID);
|
spdyHeadersFrame.setStreamId(testStreamID);
|
||||||
sessionHandler.writeInbound(spdyHeadersFrame);
|
sessionHandler.writeInbound(spdyHeadersFrame);
|
||||||
assertRstStream(sessionHandler.readOutbound(), testStreamID, SpdyStreamStatus.INVALID_STREAM);
|
assertRstStream(sessionHandler.readOutbound(), testStreamID, SpdyStreamStatus.INVALID_STREAM);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
|
|
||||||
// Check if session handler returns PROTOCOL_ERROR if it receives
|
// Check if session handler returns PROTOCOL_ERROR if it receives
|
||||||
// an invalid HEADERS frame
|
// an invalid HEADERS frame
|
||||||
@ -224,21 +222,21 @@ public class SpdySessionHandlerTest {
|
|||||||
spdyHeadersFrame.setInvalid();
|
spdyHeadersFrame.setInvalid();
|
||||||
sessionHandler.writeInbound(spdyHeadersFrame);
|
sessionHandler.writeInbound(spdyHeadersFrame);
|
||||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
|
|
||||||
// Check if session handler returns identical local PINGs
|
// Check if session handler returns identical local PINGs
|
||||||
sessionHandler.writeInbound(localPingFrame);
|
sessionHandler.writeInbound(localPingFrame);
|
||||||
assertPing(sessionHandler.readOutbound(), localPingFrame.getId());
|
assertPing(sessionHandler.readOutbound(), localPingFrame.getId());
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
|
|
||||||
// Check if session handler ignores un-initiated remote PINGs
|
// Check if session handler ignores un-initiated remote PINGs
|
||||||
sessionHandler.writeInbound(remotePingFrame);
|
sessionHandler.writeInbound(remotePingFrame);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
|
|
||||||
// Check if session handler sends a GOAWAY frame when closing
|
// Check if session handler sends a GOAWAY frame when closing
|
||||||
sessionHandler.writeInbound(closeMessage);
|
sessionHandler.writeInbound(closeMessage);
|
||||||
assertGoAway(sessionHandler.readOutbound(), localStreamID);
|
assertGoAway(sessionHandler.readOutbound(), localStreamID);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
localStreamID += 2;
|
localStreamID += 2;
|
||||||
|
|
||||||
// Check if session handler returns REFUSED_STREAM if it receives
|
// Check if session handler returns REFUSED_STREAM if it receives
|
||||||
@ -246,13 +244,13 @@ public class SpdySessionHandlerTest {
|
|||||||
spdySynStreamFrame.setStreamId(localStreamID);
|
spdySynStreamFrame.setStreamId(localStreamID);
|
||||||
sessionHandler.writeInbound(spdySynStreamFrame);
|
sessionHandler.writeInbound(spdySynStreamFrame);
|
||||||
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
assertRstStream(sessionHandler.readOutbound(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
|
|
||||||
// Check if session handler ignores Data frames after sending
|
// Check if session handler ignores Data frames after sending
|
||||||
// a GOAWAY frame
|
// a GOAWAY frame
|
||||||
spdyDataFrame.setStreamId(localStreamID);
|
spdyDataFrame.setStreamId(localStreamID);
|
||||||
sessionHandler.writeInbound(spdyDataFrame);
|
sessionHandler.writeInbound(spdyDataFrame);
|
||||||
Assert.assertNull(sessionHandler.readOutbound());
|
assertNull(sessionHandler.readOutbound());
|
||||||
|
|
||||||
sessionHandler.finish();
|
sessionHandler.finish();
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ package io.netty.util.internal.jzlib;
|
|||||||
|
|
||||||
import io.netty.util.internal.jzlib.JZlib.WrapperType;
|
import io.netty.util.internal.jzlib.JZlib.WrapperType;
|
||||||
|
|
||||||
|
@SuppressWarnings("MethodParameterNamingConvention")
|
||||||
final class Deflate {
|
final class Deflate {
|
||||||
|
|
||||||
private static final class Config {
|
private static final class Config {
|
||||||
|
@ -47,6 +47,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
package io.netty.util.internal.jzlib;
|
package io.netty.util.internal.jzlib;
|
||||||
|
|
||||||
|
@SuppressWarnings("MethodParameterNamingConvention")
|
||||||
final class InfCodes {
|
final class InfCodes {
|
||||||
|
|
||||||
private static final int[] inflate_mask = { 0x00000000, 0x00000001,
|
private static final int[] inflate_mask = { 0x00000000, 0x00000001,
|
||||||
|
@ -47,6 +47,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
package io.netty.util.internal.jzlib;
|
package io.netty.util.internal.jzlib;
|
||||||
|
|
||||||
|
@SuppressWarnings("MethodParameterNamingConvention")
|
||||||
final class StaticTree {
|
final class StaticTree {
|
||||||
static final short[] static_ltree = { 12, 8, 140, 8, 76, 8, 204, 8, 44, 8,
|
static final short[] static_ltree = { 12, 8, 140, 8, 76, 8, 204, 8, 44, 8,
|
||||||
172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188,
|
172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188,
|
||||||
|
@ -47,6 +47,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
package io.netty.util.internal.jzlib;
|
package io.netty.util.internal.jzlib;
|
||||||
|
|
||||||
|
@SuppressWarnings("MethodParameterNamingConvention")
|
||||||
final class Tree {
|
final class Tree {
|
||||||
// extra bits for each length code
|
// extra bits for each length code
|
||||||
static final int[] extra_lbits = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2,
|
static final int[] extra_lbits = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2,
|
||||||
|
@ -83,10 +83,10 @@ public class DiscardClientHandler extends ChannelInboundByteHandlerAdapter {
|
|||||||
|
|
||||||
// Flush the outbound buffer to the socket.
|
// Flush the outbound buffer to the socket.
|
||||||
// Once flushed, generate the same amount of traffic again.
|
// Once flushed, generate the same amount of traffic again.
|
||||||
ctx.flush().addListener(GENERATE_TRAFFIC);
|
ctx.flush().addListener(trafficGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ChannelFutureListener GENERATE_TRAFFIC = new ChannelFutureListener() {
|
private final ChannelFutureListener trafficGenerator = new ChannelFutureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(ChannelFuture future) throws Exception {
|
public void operationComplete(ChannelFuture future) throws Exception {
|
||||||
if (future.isSuccess()) {
|
if (future.isSuccess()) {
|
||||||
|
@ -112,11 +112,11 @@ public class FactorialClientHandler extends ChannelInboundMessageHandlerAdapter<
|
|||||||
|
|
||||||
ChannelFuture f = ctx.flush();
|
ChannelFuture f = ctx.flush();
|
||||||
if (!finished) {
|
if (!finished) {
|
||||||
f.addListener(SEND_NUMBERS);
|
f.addListener(numberSender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ChannelFutureListener SEND_NUMBERS = new ChannelFutureListener() {
|
private final ChannelFutureListener numberSender = new ChannelFutureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(ChannelFuture future) throws Exception {
|
public void operationComplete(ChannelFuture future) throws Exception {
|
||||||
if (future.isSuccess()) {
|
if (future.isSuccess()) {
|
||||||
|
@ -50,7 +50,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
public class LocalTransportThreadModelTest {
|
public class LocalTransportThreadModelTest {
|
||||||
|
|
||||||
private static ServerBootstrap sb;
|
private static ServerBootstrap sb;
|
||||||
private static LocalAddress ADDR;
|
private static LocalAddress localAddr;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void init() {
|
public static void init() {
|
||||||
@ -71,7 +71,7 @@ public class LocalTransportThreadModelTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ADDR = (LocalAddress) sb.bind().syncUninterruptibly().channel().localAddress();
|
localAddr = (LocalAddress) sb.bind().syncUninterruptibly().channel().localAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
@ -103,7 +103,7 @@ public class LocalTransportThreadModelTest {
|
|||||||
// h3 will be always invoked by EventExecutor 'e2'.
|
// h3 will be always invoked by EventExecutor 'e2'.
|
||||||
ch.pipeline().addLast(e2, h3);
|
ch.pipeline().addLast(e2, h3);
|
||||||
|
|
||||||
l.register(ch).sync().channel().connect(ADDR).sync();
|
l.register(ch).sync().channel().connect(localAddr).sync();
|
||||||
|
|
||||||
// Fire inbound events from all possible starting points.
|
// Fire inbound events from all possible starting points.
|
||||||
ch.pipeline().fireInboundBufferUpdated();
|
ch.pipeline().fireInboundBufferUpdated();
|
||||||
@ -231,7 +231,7 @@ public class LocalTransportThreadModelTest {
|
|||||||
.addLast(e4, h5)
|
.addLast(e4, h5)
|
||||||
.addLast(e5, h6);
|
.addLast(e5, h6);
|
||||||
|
|
||||||
l.register(ch).sync().channel().connect(ADDR).sync();
|
l.register(ch).sync().channel().connect(localAddr).sync();
|
||||||
|
|
||||||
final int ROUNDS = 1024;
|
final int ROUNDS = 1024;
|
||||||
final int ELEMS_PER_ROUNDS = 8192;
|
final int ELEMS_PER_ROUNDS = 8192;
|
||||||
|
Loading…
Reference in New Issue
Block a user