Move HTTP multipart classes to its own package / Clean-up
- Move CaseIgnoringComparable to netty-common - Add HttpConstants
This commit is contained in:
parent
c8fa42beaf
commit
0cd766df30
@ -194,7 +194,7 @@ public class CookieDecoder {
|
||||
return cookies;
|
||||
}
|
||||
|
||||
private void extractKeyValuePairs(
|
||||
private static void extractKeyValuePairs(
|
||||
String header, List<String> names, List<String> values) {
|
||||
Matcher m = PATTERN.matcher(header);
|
||||
int pos = 0;
|
||||
@ -243,7 +243,7 @@ public class CookieDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
private String decodeValue(String value) {
|
||||
private static String decodeValue(String value) {
|
||||
if (value == null) {
|
||||
return value;
|
||||
}
|
||||
|
@ -131,11 +131,11 @@ public class CookieEncoder {
|
||||
}
|
||||
if (cookie.isSecure()) {
|
||||
sb.append(CookieHeaderNames.SECURE);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
if (cookie.isHttpOnly()) {
|
||||
sb.append(CookieHeaderNames.HTTPONLY);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
if (cookie.getVersion() >= 1) {
|
||||
if (cookie.getComment() != null) {
|
||||
@ -150,18 +150,18 @@ public class CookieEncoder {
|
||||
|
||||
if (!cookie.getPorts().isEmpty()) {
|
||||
sb.append(CookieHeaderNames.PORT);
|
||||
sb.append((char) HttpCodecUtil.EQUALS);
|
||||
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
for (int port: cookie.getPorts()) {
|
||||
sb.append(port);
|
||||
sb.append((char) HttpCodecUtil.COMMA);
|
||||
sb.append((char) HttpConstants.COMMA);
|
||||
}
|
||||
sb.setCharAt(sb.length() - 1, (char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.setCharAt(sb.length() - 1, (char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
if (cookie.isDiscard()) {
|
||||
sb.append(CookieHeaderNames.DISCARD);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -195,14 +195,14 @@ public class CookieEncoder {
|
||||
if (!cookie.getPorts().isEmpty()) {
|
||||
sb.append('$');
|
||||
sb.append(CookieHeaderNames.PORT);
|
||||
sb.append((char) HttpCodecUtil.EQUALS);
|
||||
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
for (int port: cookie.getPorts()) {
|
||||
sb.append(port);
|
||||
sb.append((char) HttpCodecUtil.COMMA);
|
||||
sb.append((char) HttpConstants.COMMA);
|
||||
}
|
||||
sb.setCharAt(sb.length() - 1, (char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.setCharAt(sb.length() - 1, (char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -237,9 +237,9 @@ public class CookieEncoder {
|
||||
|
||||
private static void addUnquoted(StringBuilder sb, String name, String val) {
|
||||
sb.append(name);
|
||||
sb.append((char) HttpCodecUtil.EQUALS);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append(val);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
|
||||
private static void addQuoted(StringBuilder sb, String name, String val) {
|
||||
@ -248,17 +248,17 @@ public class CookieEncoder {
|
||||
}
|
||||
|
||||
sb.append(name);
|
||||
sb.append((char) HttpCodecUtil.EQUALS);
|
||||
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append(val.replace("\\", "\\\\").replace("\"", "\\\""));
|
||||
sb.append((char) HttpCodecUtil.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
|
||||
private static void add(StringBuilder sb, String name, int val) {
|
||||
sb.append(name);
|
||||
sb.append((char) HttpCodecUtil.EQUALS);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append(val);
|
||||
sb.append((char) HttpCodecUtil.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.util.internal.CaseIgnoringComparator;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
@ -15,59 +15,9 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
final class HttpCodecUtil {
|
||||
//space ' '
|
||||
static final byte SP = 32;
|
||||
|
||||
//tab ' '
|
||||
static final byte HT = 9;
|
||||
|
||||
/**
|
||||
* Carriage return
|
||||
*/
|
||||
static final byte CR = 13;
|
||||
|
||||
/**
|
||||
* Equals '='
|
||||
*/
|
||||
static final byte EQUALS = 61;
|
||||
|
||||
/**
|
||||
* Line feed character
|
||||
*/
|
||||
static final byte LF = 10;
|
||||
|
||||
/**
|
||||
* carriage return line feed
|
||||
*/
|
||||
static final byte[] CRLF = { CR, LF };
|
||||
|
||||
/**
|
||||
* Colon ':'
|
||||
*/
|
||||
static final byte COLON = 58;
|
||||
|
||||
/**
|
||||
* Semicolon ';'
|
||||
*/
|
||||
static final byte SEMICOLON = 59;
|
||||
|
||||
/**
|
||||
* comma ','
|
||||
*/
|
||||
static final byte COMMA = 44;
|
||||
|
||||
static final byte DOUBLE_QUOTE = '"';
|
||||
|
||||
static final Charset DEFAULT_CHARSET = CharsetUtil.UTF_8;
|
||||
|
||||
private HttpCodecUtil() {
|
||||
}
|
||||
|
||||
static void validateHeaderName(String name) {
|
||||
if (name == null) {
|
||||
@ -167,4 +117,7 @@ final class HttpCodecUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private HttpCodecUtil() {
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public final class HttpConstants {
|
||||
|
||||
/**
|
||||
* Horizontal space
|
||||
*/
|
||||
public static final byte SP = 32;
|
||||
|
||||
/**
|
||||
* Horizontal tab
|
||||
*/
|
||||
public static final byte HT = 9;
|
||||
|
||||
/**
|
||||
* Carriage return
|
||||
*/
|
||||
public static final byte CR = 13;
|
||||
|
||||
/**
|
||||
* Equals '='
|
||||
*/
|
||||
public static final byte EQUALS = 61;
|
||||
|
||||
/**
|
||||
* Line feed character
|
||||
*/
|
||||
public static final byte LF = 10;
|
||||
|
||||
/**
|
||||
* Colon ':'
|
||||
*/
|
||||
public static final byte COLON = 58;
|
||||
|
||||
/**
|
||||
* Semicolon ';'
|
||||
*/
|
||||
public static final byte SEMICOLON = 59;
|
||||
|
||||
/**
|
||||
* Comma ','
|
||||
*/
|
||||
public static final byte COMMA = 44;
|
||||
|
||||
/**
|
||||
* Double quote '"'
|
||||
*/
|
||||
public static final byte DOUBLE_QUOTE = '"';
|
||||
|
||||
/**
|
||||
* Default character set (UTF-8)
|
||||
*/
|
||||
public static final Charset DEFAULT_CHARSET = CharsetUtil.UTF_8;
|
||||
|
||||
private HttpConstants() {
|
||||
// Unused
|
||||
}
|
||||
}
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.util.internal.CaseIgnoringComparator;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@ -324,7 +326,7 @@ public class HttpHeaders {
|
||||
/**
|
||||
* {@code "boundary"}
|
||||
*/
|
||||
static final String BOUNDARY = "boundary";
|
||||
public static final String BOUNDARY = "boundary";
|
||||
/**
|
||||
* {@code "bytes"}
|
||||
*/
|
||||
@ -380,7 +382,7 @@ public class HttpHeaders {
|
||||
/**
|
||||
* {@code "multipart/form-data"}
|
||||
*/
|
||||
static final String MULTIPART_FORM_DATA = "multipart/form-data";
|
||||
public static final String MULTIPART_FORM_DATA = "multipart/form-data";
|
||||
/**
|
||||
* {@code "must-revalidate"}
|
||||
*/
|
||||
|
@ -334,12 +334,12 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<Object, HttpMe
|
||||
case READ_CHUNK_DELIMITER: {
|
||||
for (;;) {
|
||||
byte next = buffer.readByte();
|
||||
if (next == HttpCodecUtil.CR) {
|
||||
if (buffer.readByte() == HttpCodecUtil.LF) {
|
||||
if (next == HttpConstants.CR) {
|
||||
if (buffer.readByte() == HttpConstants.LF) {
|
||||
checkpoint(State.READ_CHUNK_SIZE);
|
||||
return null;
|
||||
}
|
||||
} else if (next == HttpCodecUtil.LF) {
|
||||
} else if (next == HttpConstants.LF) {
|
||||
checkpoint(State.READ_CHUNK_SIZE);
|
||||
return null;
|
||||
}
|
||||
@ -522,14 +522,14 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<Object, HttpMe
|
||||
headerSize ++;
|
||||
|
||||
switch (nextByte) {
|
||||
case HttpCodecUtil.CR:
|
||||
case HttpConstants.CR:
|
||||
nextByte = (char) buffer.readByte();
|
||||
headerSize ++;
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
break loop;
|
||||
}
|
||||
break;
|
||||
case HttpCodecUtil.LF:
|
||||
case HttpConstants.LF:
|
||||
break loop;
|
||||
}
|
||||
|
||||
@ -573,12 +573,12 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<Object, HttpMe
|
||||
int lineLength = 0;
|
||||
while (true) {
|
||||
byte nextByte = buffer.readByte();
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
nextByte = buffer.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
return sb.toString();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
return sb.toString();
|
||||
} else {
|
||||
if (lineLength >= maxLineLength) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static io.netty.buffer.ChannelBuffers.*;
|
||||
import static io.netty.handler.codec.http.HttpCodecUtil.*;
|
||||
import static io.netty.handler.codec.http.HttpConstants.*;
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.channel.ChannelOutboundHandlerContext;
|
||||
import io.netty.handler.codec.MessageToStreamEncoder;
|
||||
@ -111,9 +111,11 @@ public abstract class HttpMessageEncoder extends MessageToStreamEncoder<Object>
|
||||
ChannelBuffer content = chunk.getContent();
|
||||
int contentLength = content.readableBytes();
|
||||
out.writeBytes(copiedBuffer(Integer.toHexString(contentLength), CharsetUtil.US_ASCII));
|
||||
out.writeBytes(CRLF);
|
||||
out.writeByte(CR);
|
||||
out.writeByte(LF);
|
||||
out.writeBytes(content, content.readerIndex(), contentLength);
|
||||
out.writeBytes(CRLF);
|
||||
out.writeByte(CR);
|
||||
out.writeByte(LF);
|
||||
}
|
||||
} else {
|
||||
if (!chunk.isLast()) {
|
||||
|
@ -15,8 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpCodecUtil.*;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpConstants.*;
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
|
||||
/**
|
||||
|
@ -15,8 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpCodecUtil.*;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpConstants.*;
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.Charset;
|
||||
@ -24,8 +26,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
/**
|
||||
* Splits an HTTP query string into a path string and key-value parameter pairs.
|
||||
* This decoder is for one time use only. Create a new instance for each URI:
|
||||
@ -73,7 +73,7 @@ public class QueryStringDecoder {
|
||||
* assume that the query string is encoded in UTF-8.
|
||||
*/
|
||||
public QueryStringDecoder(String uri) {
|
||||
this(uri, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
this(uri, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +81,7 @@ public class QueryStringDecoder {
|
||||
* specified charset.
|
||||
*/
|
||||
public QueryStringDecoder(String uri, boolean hasPath) {
|
||||
this(uri, HttpCodecUtil.DEFAULT_CHARSET, hasPath);
|
||||
this(uri, HttpConstants.DEFAULT_CHARSET, hasPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +128,7 @@ public class QueryStringDecoder {
|
||||
* assume that the query string is encoded in UTF-8.
|
||||
*/
|
||||
public QueryStringDecoder(URI uri) {
|
||||
this(uri, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
this(uri, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,7 +154,7 @@ public class QueryStringDecoder {
|
||||
throw new IllegalArgumentException(
|
||||
"maxParams: " + maxParams + " (expected: a positive integer)");
|
||||
}
|
||||
|
||||
|
||||
String rawPath = uri.getRawPath();
|
||||
if (rawPath != null) {
|
||||
hasPath = true;
|
||||
@ -162,7 +162,7 @@ public class QueryStringDecoder {
|
||||
rawPath = "";
|
||||
hasPath = false;
|
||||
}
|
||||
// Also take care of cut of things like "http://localhost"
|
||||
// Also take care of cut of things like "http://localhost"
|
||||
String newUri = rawPath + "?" + uri.getRawQuery();
|
||||
|
||||
// http://en.wikipedia.org/wiki/Query_string
|
||||
@ -288,7 +288,7 @@ public class QueryStringDecoder {
|
||||
* escape sequence.
|
||||
*/
|
||||
public static String decodeComponent(final String s) {
|
||||
return decodeComponent(s, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
return decodeComponent(s, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ public class QueryStringEncoder {
|
||||
* path string. The encoder will encode the URI in UTF-8.
|
||||
*/
|
||||
public QueryStringEncoder(String uri) {
|
||||
this(uri, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
this(uri, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,10 +13,11 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.buffer.ChannelBuffers;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -269,7 +270,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
|
||||
@Override
|
||||
public String getString() throws IOException {
|
||||
return getString(HttpCodecUtil.DEFAULT_CHARSET);
|
||||
return getString(HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -279,7 +280,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
}
|
||||
if (encoding == null) {
|
||||
byte[] array = readFrom(file);
|
||||
return new String(array, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
return new String(array, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
byte[] array = readFrom(file);
|
||||
return new String(array, encoding);
|
||||
@ -325,7 +326,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
|
||||
* @return the array of bytes
|
||||
* @throws IOException
|
||||
*/
|
||||
private byte[] readFrom(File src) throws IOException {
|
||||
private static byte[] readFrom(File src) throws IOException {
|
||||
long srcsize = src.length();
|
||||
if (srcsize > Integer.MAX_VALUE) {
|
||||
throw new IllegalArgumentException(
|
@ -13,7 +13,9 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@ -25,7 +27,7 @@ public abstract class AbstractHttpData implements HttpData {
|
||||
protected final String name;
|
||||
protected long definedSize;
|
||||
protected long size;
|
||||
protected Charset charset = HttpCodecUtil.DEFAULT_CHARSET;
|
||||
protected Charset charset = HttpConstants.DEFAULT_CHARSET;
|
||||
protected boolean completed;
|
||||
|
||||
public AbstractHttpData(String name, Charset charset, long size) {
|
@ -13,10 +13,11 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.buffer.ChannelBuffers;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -145,7 +146,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||
|
||||
@Override
|
||||
public String getString() {
|
||||
return getString(HttpCodecUtil.DEFAULT_CHARSET);
|
||||
return getString(HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -154,7 +155,7 @@ public abstract class AbstractMemoryHttpData extends AbstractHttpData {
|
||||
return "";
|
||||
}
|
||||
if (encoding == null) {
|
||||
return getString(HttpCodecUtil.DEFAULT_CHARSET);
|
||||
return getString(HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
return channelBuffer.toString(encoding);
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -13,7 +13,9 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
@ -13,12 +13,13 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import java.io.IOException;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.buffer.ChannelBuffers;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Disk implementation of Attributes
|
||||
@ -37,7 +38,7 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
|
||||
* @param name
|
||||
*/
|
||||
public DiskAttribute(String name) {
|
||||
super(name, HttpCodecUtil.DEFAULT_CHARSET, 0);
|
||||
super(name, HttpConstants.DEFAULT_CHARSET, 0);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@ -48,7 +49,7 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
|
||||
* @throws IOException
|
||||
*/
|
||||
public DiskAttribute(String name, String value) throws IOException {
|
||||
super(name, HttpCodecUtil.DEFAULT_CHARSET, 0); // Attribute have no default size
|
||||
super(name, HttpConstants.DEFAULT_CHARSET, 0); // Attribute have no default size
|
||||
setValue(value);
|
||||
}
|
||||
|
@ -13,7 +13,9 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
/**
|
||||
* FileUpload interface that could be in memory, on temporary file or any other implementations.
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
@ -13,7 +13,9 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.util.CharsetUtil;
|
@ -13,7 +13,19 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.buffer.ChannelBuffers;
|
||||
import io.netty.handler.codec.http.HttpChunk;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostBodyUtil.SeekAheadNoBackArrayException;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostBodyUtil.SeekAheadOptimize;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostBodyUtil.TransferEncodingMechanism;
|
||||
import io.netty.util.internal.CaseIgnoringComparator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -24,12 +36,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.buffer.ChannelBuffers;
|
||||
import io.netty.handler.codec.http.HttpPostBodyUtil.SeekAheadNoBackArrayException;
|
||||
import io.netty.handler.codec.http.HttpPostBodyUtil.SeekAheadOptimize;
|
||||
import io.netty.handler.codec.http.HttpPostBodyUtil.TransferEncodingMechanism;
|
||||
|
||||
/**
|
||||
* This decoder will decode Body and can handle POST BODY.
|
||||
*/
|
||||
@ -126,7 +132,7 @@ public class HttpPostRequestDecoder {
|
||||
public HttpPostRequestDecoder(HttpRequest request)
|
||||
throws ErrorDataDecoderException, IncompatibleDataDecoderException {
|
||||
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE),
|
||||
request, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
request, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,7 +145,7 @@ public class HttpPostRequestDecoder {
|
||||
*/
|
||||
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request)
|
||||
throws ErrorDataDecoderException, IncompatibleDataDecoderException {
|
||||
this(factory, request, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
this(factory, request, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -471,11 +477,11 @@ public class HttpPostRequestDecoder {
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos));
|
||||
firstpos = currentpos;
|
||||
contRead = true;
|
||||
} else if (read == HttpCodecUtil.CR) {
|
||||
} else if (read == HttpConstants.CR) {
|
||||
if (undecodedChunk.readable()) {
|
||||
read = (char) undecodedChunk.readUnsignedByte();
|
||||
currentpos++;
|
||||
if (read == HttpCodecUtil.LF) {
|
||||
if (read == HttpConstants.LF) {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 2;
|
||||
setFinalBuffer(
|
||||
@ -490,7 +496,7 @@ public class HttpPostRequestDecoder {
|
||||
} else {
|
||||
currentpos--;
|
||||
}
|
||||
} else if (read == HttpCodecUtil.LF) {
|
||||
} else if (read == HttpConstants.LF) {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 1;
|
||||
setFinalBuffer(
|
||||
@ -597,11 +603,11 @@ public class HttpPostRequestDecoder {
|
||||
setFinalBuffer(undecodedChunk.slice(firstpos, ampersandpos - firstpos));
|
||||
firstpos = currentpos;
|
||||
contRead = true;
|
||||
} else if (read == HttpCodecUtil.CR) {
|
||||
} else if (read == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
read = (char) (sao.bytes[sao.pos ++] & 0xFF);
|
||||
currentpos++;
|
||||
if (read == HttpCodecUtil.LF) {
|
||||
if (read == HttpConstants.LF) {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 2;
|
||||
sao.setReadPosition(0);
|
||||
@ -621,7 +627,7 @@ public class HttpPostRequestDecoder {
|
||||
currentpos --;
|
||||
}
|
||||
}
|
||||
} else if (read == HttpCodecUtil.LF) {
|
||||
} else if (read == HttpConstants.LF) {
|
||||
currentStatus = MultiPartStatus.PREEPILOGUE;
|
||||
ampersandpos = currentpos - 1;
|
||||
sao.setReadPosition(0);
|
||||
@ -1213,12 +1219,12 @@ public class HttpPostRequestDecoder {
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
while (undecodedChunk.readable()) {
|
||||
byte nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
return sb.toString();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
return sb.toString();
|
||||
} else {
|
||||
sb.append((char) nextByte);
|
||||
@ -1250,17 +1256,17 @@ public class HttpPostRequestDecoder {
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
while (sao.pos < sao.limit) {
|
||||
byte nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
sao.setReadPosition(0);
|
||||
return sb.toString();
|
||||
}
|
||||
} else {
|
||||
sb.append((char) nextByte);
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
sao.setReadPosition(0);
|
||||
return sb.toString();
|
||||
} else {
|
||||
@ -1306,16 +1312,16 @@ public class HttpPostRequestDecoder {
|
||||
newLine = false;
|
||||
index = 0;
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (undecodedChunk.readable()) {
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
}
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
@ -1326,16 +1332,16 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
} else {
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (undecodedChunk.readable()) {
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
}
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
@ -1409,10 +1415,10 @@ public class HttpPostRequestDecoder {
|
||||
newLine = false;
|
||||
index = 0;
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1423,7 +1429,7 @@ public class HttpPostRequestDecoder {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1436,10 +1442,10 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
} else {
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1450,7 +1456,7 @@ public class HttpPostRequestDecoder {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1514,16 +1520,16 @@ public class HttpPostRequestDecoder {
|
||||
newLine = false;
|
||||
index = 0;
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (undecodedChunk.readable()) {
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
}
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
@ -1533,16 +1539,16 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
} else {
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (undecodedChunk.readable()) {
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
}
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
@ -1618,10 +1624,10 @@ public class HttpPostRequestDecoder {
|
||||
newLine = false;
|
||||
index = 0;
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1631,7 +1637,7 @@ public class HttpPostRequestDecoder {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1643,10 +1649,10 @@ public class HttpPostRequestDecoder {
|
||||
}
|
||||
} else {
|
||||
// continue until end of line
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (sao.pos < sao.limit) {
|
||||
nextByte = sao.bytes[sao.pos ++];
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1656,7 +1662,7 @@ public class HttpPostRequestDecoder {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
}
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
@ -1698,22 +1704,22 @@ public class HttpPostRequestDecoder {
|
||||
* Clean the String from any unallowed character
|
||||
* @return the cleaned String
|
||||
*/
|
||||
private String cleanString(String field) {
|
||||
private static String cleanString(String field) {
|
||||
StringBuilder sb = new StringBuilder(field.length());
|
||||
int i = 0;
|
||||
for (i = 0; i < field.length(); i ++) {
|
||||
char nextChar = field.charAt(i);
|
||||
if (nextChar == HttpCodecUtil.COLON) {
|
||||
sb.append(HttpCodecUtil.SP);
|
||||
} else if (nextChar == HttpCodecUtil.COMMA) {
|
||||
sb.append(HttpCodecUtil.SP);
|
||||
} else if (nextChar == HttpCodecUtil.EQUALS) {
|
||||
sb.append(HttpCodecUtil.SP);
|
||||
} else if (nextChar == HttpCodecUtil.SEMICOLON) {
|
||||
sb.append(HttpCodecUtil.SP);
|
||||
} else if (nextChar == HttpCodecUtil.HT) {
|
||||
sb.append(HttpCodecUtil.SP);
|
||||
} else if (nextChar == HttpCodecUtil.DOUBLE_QUOTE) {
|
||||
if (nextChar == HttpConstants.COLON) {
|
||||
sb.append(HttpConstants.SP);
|
||||
} else if (nextChar == HttpConstants.COMMA) {
|
||||
sb.append(HttpConstants.SP);
|
||||
} else if (nextChar == HttpConstants.EQUALS) {
|
||||
sb.append(HttpConstants.SP);
|
||||
} else if (nextChar == HttpConstants.SEMICOLON) {
|
||||
sb.append(HttpConstants.SP);
|
||||
} else if (nextChar == HttpConstants.HT) {
|
||||
sb.append(HttpConstants.SP);
|
||||
} else if (nextChar == HttpConstants.DOUBLE_QUOTE) {
|
||||
// nothing added, just removes it
|
||||
} else {
|
||||
sb.append(nextChar);
|
||||
@ -1731,18 +1737,18 @@ public class HttpPostRequestDecoder {
|
||||
return false;
|
||||
}
|
||||
byte nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.CR) {
|
||||
if (nextByte == HttpConstants.CR) {
|
||||
if (!undecodedChunk.readable()) {
|
||||
undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 1);
|
||||
return false;
|
||||
}
|
||||
nextByte = undecodedChunk.readByte();
|
||||
if (nextByte == HttpCodecUtil.LF) {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
return true;
|
||||
}
|
||||
undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 2);
|
||||
return false;
|
||||
} else if (nextByte == HttpCodecUtil.LF) {
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
return true;
|
||||
}
|
||||
undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 1);
|
||||
@ -1754,7 +1760,7 @@ public class HttpPostRequestDecoder {
|
||||
* @param sb
|
||||
* @return the array of 2 Strings
|
||||
*/
|
||||
private String[] splitHeaderContentType(String sb) {
|
||||
private static String[] splitHeaderContentType(String sb) {
|
||||
int size = sb.length();
|
||||
int aStart;
|
||||
int aEnd;
|
||||
@ -1780,7 +1786,7 @@ public class HttpPostRequestDecoder {
|
||||
* @return an array of String where rank 0 is the name of the header, follows by several
|
||||
* values that were separated by ';' or ','
|
||||
*/
|
||||
private String[] splitMultipartHeader(String sb) {
|
||||
private static String[] splitMultipartHeader(String sb) {
|
||||
ArrayList<String> headers = new ArrayList<String>(1);
|
||||
int nameStart;
|
||||
int nameEnd;
|
@ -13,7 +13,17 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.buffer.ChannelBuffers;
|
||||
import io.netty.handler.codec.http.DefaultHttpChunk;
|
||||
import io.netty.handler.codec.http.HttpChunk;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.stream.ChunkedInput;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -25,10 +35,6 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Random;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.buffer.ChannelBuffers;
|
||||
import io.netty.handler.stream.ChunkedInput;
|
||||
|
||||
/**
|
||||
* This encoder will help to encode Request for a FORM as POST.
|
||||
*/
|
||||
@ -56,11 +62,11 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||
/**
|
||||
* InterfaceHttpData for Body (without encoding)
|
||||
*/
|
||||
private List<InterfaceHttpData> bodyListDatas;
|
||||
private final List<InterfaceHttpData> bodyListDatas;
|
||||
/**
|
||||
* The final Multipart List of InterfaceHttpData including encoding
|
||||
*/
|
||||
private List<InterfaceHttpData> multipartHttpDatas;
|
||||
private final List<InterfaceHttpData> multipartHttpDatas;
|
||||
|
||||
/**
|
||||
* Does this request is a Multipart request
|
||||
@ -92,7 +98,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||
public HttpPostRequestEncoder(HttpRequest request, boolean multipart)
|
||||
throws ErrorDataEncoderException {
|
||||
this(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE),
|
||||
request, multipart, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
request, multipart, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,7 +111,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||
*/
|
||||
public HttpPostRequestEncoder(HttpDataFactory factory, HttpRequest request, boolean multipart)
|
||||
throws ErrorDataEncoderException {
|
||||
this(factory, request, multipart, HttpCodecUtil.DEFAULT_CHARSET);
|
||||
this(factory, request, multipart, HttpConstants.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,7 +207,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
||||
*
|
||||
* @return a newly generated Delimiter (either for DATA or MIXED)
|
||||
*/
|
||||
private String getNewMultipartDelimiter() {
|
||||
private static String getNewMultipartDelimiter() {
|
||||
// construct a generated delimiter
|
||||
Random random = new Random();
|
||||
return Long.toHexString(random.nextLong()).toLowerCase();
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
/**
|
||||
* Interface for all Objects that could be encoded/decoded using HttpPostRequestEncoder/Decoder
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -13,12 +13,13 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import java.io.IOException;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
import io.netty.buffer.ChannelBuffers;
|
||||
import io.netty.handler.codec.http.HttpConstants;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Memory implementation of Attributes
|
||||
@ -26,7 +27,7 @@ import io.netty.buffer.ChannelBuffers;
|
||||
public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute {
|
||||
|
||||
public MemoryAttribute(String name) {
|
||||
super(name, HttpCodecUtil.DEFAULT_CHARSET, 0);
|
||||
super(name, HttpConstants.DEFAULT_CHARSET, 0);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@ -37,7 +38,7 @@ public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute
|
||||
* @throws IOException
|
||||
*/
|
||||
public MemoryAttribute(String name, String value) throws IOException {
|
||||
super(name, HttpCodecUtil.DEFAULT_CHARSET, 0); // Attribute have no default size
|
||||
super(name, HttpConstants.DEFAULT_CHARSET, 0); // Attribute have no default size
|
||||
setValue(value);
|
||||
}
|
||||
|
@ -13,7 +13,9 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.handler.codec.http.multipart;
|
||||
|
||||
import io.netty.buffer.ChannelBuffer;
|
||||
|
@ -15,11 +15,11 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.handler.codec.compression.ZlibWrapper;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import io.netty.handler.codec.compression.ZlibWrapper;
|
||||
|
||||
public class HttpContentCompressorTest {
|
||||
@Test
|
||||
public void testGetTargetContentEncoding() throws Exception {
|
||||
@ -51,9 +51,7 @@ public class HttpContentCompressorTest {
|
||||
targetEncoding = "deflate";
|
||||
break;
|
||||
default:
|
||||
if (targetWrapper != null) {
|
||||
Assert.fail();
|
||||
}
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(contentEncoding, targetEncoding);
|
||||
|
@ -13,16 +13,16 @@
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
package io.netty.util.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
final class CaseIgnoringComparator implements Comparator<String>, Serializable {
|
||||
public final class CaseIgnoringComparator implements Comparator<String>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4582133183775373862L;
|
||||
|
||||
static final CaseIgnoringComparator INSTANCE = new CaseIgnoringComparator();
|
||||
public static final CaseIgnoringComparator INSTANCE = new CaseIgnoringComparator();
|
||||
|
||||
private CaseIgnoringComparator() {
|
||||
}
|
||||
@ -32,6 +32,7 @@ final class CaseIgnoringComparator implements Comparator<String>, Serializable {
|
||||
return o1.compareToIgnoreCase(o2);
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
private Object readResolve() {
|
||||
return INSTANCE;
|
||||
}
|
@ -28,18 +28,18 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.socket.nio.NioClientSocketChannelFactory;
|
||||
import io.netty.handler.codec.http.CookieEncoder;
|
||||
import io.netty.handler.codec.http.DefaultHttpDataFactory;
|
||||
import io.netty.handler.codec.http.DefaultHttpRequest;
|
||||
import io.netty.handler.codec.http.DiskAttribute;
|
||||
import io.netty.handler.codec.http.DiskFileUpload;
|
||||
import io.netty.handler.codec.http.HttpDataFactory;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import io.netty.handler.codec.http.HttpPostRequestEncoder;
|
||||
import io.netty.handler.codec.http.HttpPostRequestEncoder.ErrorDataEncoderException;
|
||||
import io.netty.handler.codec.http.multipart.DefaultHttpDataFactory;
|
||||
import io.netty.handler.codec.http.multipart.DiskAttribute;
|
||||
import io.netty.handler.codec.http.multipart.DiskFileUpload;
|
||||
import io.netty.handler.codec.http.multipart.HttpDataFactory;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostRequestEncoder;
|
||||
import io.netty.handler.codec.http.multipart.InterfaceHttpData;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostRequestEncoder.ErrorDataEncoderException;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import io.netty.handler.codec.http.InterfaceHttpData;
|
||||
import io.netty.handler.codec.http.QueryStringEncoder;
|
||||
|
||||
/**
|
||||
|
@ -34,29 +34,29 @@ import io.netty.channel.Channels;
|
||||
import io.netty.channel.ExceptionEvent;
|
||||
import io.netty.channel.MessageEvent;
|
||||
import io.netty.channel.SimpleChannelUpstreamHandler;
|
||||
import io.netty.handler.codec.http.Attribute;
|
||||
import io.netty.handler.codec.http.Cookie;
|
||||
import io.netty.handler.codec.http.CookieDecoder;
|
||||
import io.netty.handler.codec.http.CookieEncoder;
|
||||
import io.netty.handler.codec.http.DefaultHttpDataFactory;
|
||||
import io.netty.handler.codec.http.DefaultHttpResponse;
|
||||
import io.netty.handler.codec.http.DiskAttribute;
|
||||
import io.netty.handler.codec.http.DiskFileUpload;
|
||||
import io.netty.handler.codec.http.FileUpload;
|
||||
import io.netty.handler.codec.http.HttpChunk;
|
||||
import io.netty.handler.codec.http.HttpDataFactory;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpPostRequestDecoder;
|
||||
import io.netty.handler.codec.http.HttpPostRequestDecoder.EndOfDataDecoderException;
|
||||
import io.netty.handler.codec.http.HttpPostRequestDecoder.ErrorDataDecoderException;
|
||||
import io.netty.handler.codec.http.HttpPostRequestDecoder.IncompatibleDataDecoderException;
|
||||
import io.netty.handler.codec.http.HttpPostRequestDecoder.NotEnoughDataDecoderException;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponse;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
import io.netty.handler.codec.http.InterfaceHttpData;
|
||||
import io.netty.handler.codec.http.InterfaceHttpData.HttpDataType;
|
||||
import io.netty.handler.codec.http.multipart.Attribute;
|
||||
import io.netty.handler.codec.http.multipart.DefaultHttpDataFactory;
|
||||
import io.netty.handler.codec.http.multipart.DiskAttribute;
|
||||
import io.netty.handler.codec.http.multipart.DiskFileUpload;
|
||||
import io.netty.handler.codec.http.multipart.FileUpload;
|
||||
import io.netty.handler.codec.http.multipart.HttpDataFactory;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
|
||||
import io.netty.handler.codec.http.multipart.InterfaceHttpData;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.IncompatibleDataDecoderException;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException;
|
||||
import io.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType;
|
||||
import io.netty.handler.codec.http.QueryStringDecoder;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user