request edit support http2 (#388)(#51)

This commit is contained in:
wanghongenpin
2025-05-09 18:43:34 +08:00
parent 94197e9817
commit 8a06f79a48
11 changed files with 100 additions and 36 deletions

View File

@@ -161,9 +161,14 @@ class RequestEditorState extends State<MobileRequestEditor> with SingleTickerPro
return _HttpWidget(
key: responseKey,
title: Row(children: [
Text(response?.protocolVersion ?? '',
style: const TextStyle(fontWeight: FontWeight.w500, color: Colors.blue)),
const SizedBox(width: 10),
Text("${localizations.statusCode}: ", style: const TextStyle(fontWeight: FontWeight.w500)),
const SizedBox(width: 10),
Text(response?.status.toString() ?? "", style: const TextStyle(color: Colors.blue))
Text(response?.status.toString() ?? "",
style:
TextStyle(color: response?.status.isSuccessful() == true ? Colors.blue : Colors.red))
]),
readOnly: true,
message: response);
@@ -179,7 +184,9 @@ class RequestEditorState extends State<MobileRequestEditor> with SingleTickerPro
var requestBody = requestKey.currentState?.getBody();
String url = currentState.requestUrl.text;
HttpRequest request = HttpRequest(HttpMethod.valueOf(currentState.requestMethod), Uri.parse(url).toString());
HttpRequest request = HttpRequest(HttpMethod.valueOf(currentState.requestMethod), Uri.parse(url).toString(),
protocolVersion: this.request?.protocolVersion ?? "HTTP/1.1");
request.headers.addAll(headers);
request.body = requestBody == null ? null : utf8.encode(requestBody);

View File

@@ -18,7 +18,12 @@ class RequestSequence extends StatefulWidget {
final Function(List<HttpRequest>)? onRemove;
const RequestSequence(
{super.key, required this.container, required this.proxyServer, this.displayDomain = true, this.onRemove, this.sortDesc});
{super.key,
required this.container,
required this.proxyServer,
this.displayDomain = true,
this.onRemove,
this.sortDesc});
@override
State<StatefulWidget> createState() {
@@ -154,9 +159,14 @@ class RequestSequenceState extends State<RequestSequence> with AutomaticKeepAliv
Divider(thickness: 0.2, height: 0, color: Theme.of(context).dividerColor),
itemCount: view.length,
itemBuilder: (context, index) {
final requestId = view.elementAt(index).requestId;
// 确保每个 requestId 对应唯一的 GlobalKey
final key = indexes.putIfAbsent(requestId, () => GlobalKey<RequestRowState>());
return RequestRow(
index: sortDesc ? view.length - index : index,
key: indexes[view.elementAt(index).requestId] ??= GlobalKey(),
key: key,
request: view.elementAt(index),
proxyServer: widget.proxyServer,
displayDomain: widget.displayDomain,