content-type video

This commit is contained in:
wanghongenpin
2024-08-10 21:49:42 +08:00
parent 95c01c3ed2
commit 00f196d0cc
5 changed files with 18 additions and 8 deletions

View File

@@ -309,11 +309,12 @@ class ChannelPipeline extends ChannelHandler<Uint8List> {
Channel? remoteChannel = channelContext.getAttribute(channel.id);
//大body 不解析直接转发
if (buffer.length > Codec.maxBodyLength) {
relay(channel, remoteChannel!);
handler.channelRead(channelContext, channel, buffer.bytes);
buffer.clear();
if (buffer.length > Codec.maxBodyLength && handler is! RelayHandler) {
logger.w("[$channel] forward large body");
relay(channel, remoteChannel!);
var body = buffer.bytes;
buffer.clear();
handler.channelRead(channelContext, channel, body);
return;
}

View File

@@ -37,6 +37,7 @@ abstract class HttpMessage {
"application/x-www-form-urlencoded": ContentType.formUrl,
"form-data": ContentType.formData,
"image": ContentType.image,
"video": ContentType.video,
"application/json": ContentType.json
};
@@ -195,6 +196,7 @@ enum ContentType {
css,
font,
image,
video,
http;
static ContentType valueOf(String name) {
@@ -203,7 +205,7 @@ enum ContentType {
//是否是二进制
bool get isBinary {
return this == image || this == font;
return this == image || this == font || this == video;
}
}

View File

@@ -11,6 +11,7 @@ const contentMap = {
ContentType.html: Icons.html,
ContentType.js: Icons.javascript,
ContentType.image: Icons.image,
ContentType.video: Icons.video_call,
ContentType.text: Icons.text_fields,
ContentType.css: Icons.css,
ContentType.font: Icons.font_download,

View File

@@ -358,6 +358,9 @@ class _BodyState extends State<_Body> {
if (type == ViewType.image) {
return Image.memory(Uint8List.fromList(message?.body ?? []), fit: BoxFit.none);
}
if (type == ViewType.video) {
return const Center(child: Text("video not support preview"));
}
if (type == ViewType.hex) {
return SelectableText(message!.body!.map(intToHex).join(" "), contextMenuBuilder: contextMenu);
}
@@ -379,6 +382,11 @@ class Tabs {
return tabs;
}
if (contentType == ContentType.video) {
tabs.list.add(ViewType.hex);
return tabs;
}
if (contentType == ContentType.json) {
tabs.list.add(ViewType.jsonText);
}
@@ -411,6 +419,7 @@ enum ViewType {
jsonText("JSON Text"),
html("HTML"),
image("Image"),
video("Video"),
css("CSS"),
js("JavaScript"),
hex("Hex"),

View File

@@ -47,9 +47,6 @@ class _LeftNavigationBarState extends State<LeftNavigationBar> {
@override
Widget build(BuildContext context) {
widget.controller.addListener(() {
print('page: ${widget.controller.page}');
});
return ValueListenableBuilder(
valueListenable: widget.selectIndex,