mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-06-03 17:25:48 +08:00
chunked encoding content length
This commit is contained in:
@@ -77,7 +77,7 @@ class Channel {
|
||||
remotePort = _socket.remotePort;
|
||||
|
||||
///返回此channel的全局唯一标识符。
|
||||
String get id => _id.toRadixString(16);
|
||||
String get id => _id.toRadixString(36);
|
||||
|
||||
Socket get socket => _socket;
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import '../../utils/compress.dart';
|
||||
import 'http.dart';
|
||||
import 'http_headers.dart';
|
||||
|
||||
|
||||
class ParserException implements Exception {
|
||||
final String message;
|
||||
final String? source;
|
||||
@@ -162,11 +161,12 @@ abstract class HttpCodec<T extends HttpMessage> implements Codec<T> {
|
||||
}
|
||||
|
||||
//请求头
|
||||
bool isChunked = message.headers.isChunked;
|
||||
message.headers.remove(HttpHeaders.TRANSFER_ENCODING);
|
||||
|
||||
if (body != null && body.isNotEmpty) {
|
||||
if (body != null && (body.isNotEmpty || isChunked)) {
|
||||
message.headers.contentLength = body.length;
|
||||
} else if (message.contentLength != 0){
|
||||
} else if (message.contentLength != 0) {
|
||||
message.headers.remove(HttpHeaders.CONTENT_LENGTH);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ abstract class HttpMessage {
|
||||
List<int>? body;
|
||||
String? remoteAddress;
|
||||
|
||||
String requestId = (DateTime.now().millisecondsSinceEpoch + Random().nextInt(99999)).toRadixString(16);
|
||||
String requestId = (DateTime.now().millisecondsSinceEpoch + Random().nextInt(99999)).toRadixString(36);
|
||||
int? streamId; // http2 streamId
|
||||
HttpMessage(this.protocolVersion);
|
||||
|
||||
@@ -266,6 +266,7 @@ enum HttpMethod {
|
||||
trace("TRACE"),
|
||||
connect("CONNECT"),
|
||||
propfind("PROPFIND"),
|
||||
report("REPORT"),
|
||||
;
|
||||
|
||||
final String name;
|
||||
@@ -280,6 +281,10 @@ enum HttpMethod {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static List<HttpMethod> methods() {
|
||||
return values.where((method) => method != HttpMethod.propfind && method != HttpMethod.report).toList();
|
||||
}
|
||||
}
|
||||
|
||||
///HTTP响应状态。
|
||||
|
||||
@@ -85,9 +85,10 @@ class HttpHeaders {
|
||||
return _headers[originalHeaderName];
|
||||
}
|
||||
|
||||
void remove(String name) {
|
||||
bool remove(String name) {
|
||||
var originalHeaderName = _originalHeaderNames.remove(name.toLowerCase());
|
||||
_headers.remove(originalHeaderName);
|
||||
return originalHeaderName != null;
|
||||
}
|
||||
|
||||
int? getInt(String name) {
|
||||
|
||||
Reference in New Issue
Block a user