fix: use json openclaw task submit
This commit is contained in:
parent
f7e67e7263
commit
2fe389c994
@ -566,7 +566,7 @@ class GatewayAcpClient {
|
||||
);
|
||||
httpRequest.headers.set(
|
||||
HttpHeaders.acceptHeader,
|
||||
'text/event-stream, application/json',
|
||||
_httpAcceptHeaderFor(endpoint, request.method),
|
||||
);
|
||||
final authorization = await _resolveAuthorizationHeader(
|
||||
endpoint,
|
||||
@ -1128,6 +1128,14 @@ bool _isOpenClawTaskSubmitMethod(String method) {
|
||||
return normalized == 'session.start' || normalized == 'session.message';
|
||||
}
|
||||
|
||||
String _httpAcceptHeaderFor(Uri endpoint, String method) {
|
||||
if (_isOpenClawTaskSubmitEndpoint(endpoint) &&
|
||||
_isOpenClawTaskSubmitMethod(method)) {
|
||||
return 'application/json';
|
||||
}
|
||||
return 'text/event-stream, application/json';
|
||||
}
|
||||
|
||||
class _GatewayAcpRpcRequest {
|
||||
const _GatewayAcpRpcRequest({
|
||||
required this.id,
|
||||
|
||||
@ -244,6 +244,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(capture.authorizationHeader, 'Bearer bridge-token');
|
||||
expect(capture.acceptHeader, 'text/event-stream, application/json');
|
||||
expect(capture.requestPath, '/acp/rpc');
|
||||
expect((response['result'] as Map)['ok'], true);
|
||||
});
|
||||
@ -672,6 +673,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(capture.authorizationHeader, 'Bearer bridge-token');
|
||||
expect(capture.acceptHeader, 'application/json');
|
||||
expect(capture.requestPath, '/gateway/openclaw');
|
||||
expect(capture.requestPath, isNot(contains('/acp-server')));
|
||||
expect(capture.requestPath, isNot(contains('/acp-server/gateway')));
|
||||
@ -715,6 +717,7 @@ void main() {
|
||||
onUpdate: (_) {},
|
||||
);
|
||||
|
||||
expect(capture.acceptHeader, 'application/json');
|
||||
expect(capture.requestPath, '/gateway/openclaw');
|
||||
expect(capture.requestBody, contains('"method":"session.message"'));
|
||||
},
|
||||
@ -1063,6 +1066,8 @@ Future<_CapturedAcpHttpServer> _startAcpHttpServer() async {
|
||||
server.listen((request) async {
|
||||
capture.authorizationHeader =
|
||||
request.headers.value(HttpHeaders.authorizationHeader) ?? '';
|
||||
capture.acceptHeader =
|
||||
request.headers.value(HttpHeaders.acceptHeader) ?? '';
|
||||
capture.requestPath = request.uri.path;
|
||||
final body = await utf8.decoder.bind(request).join();
|
||||
capture.requestBody = body;
|
||||
@ -1100,6 +1105,7 @@ class _CapturedAcpHttpServer {
|
||||
final HttpServer _server;
|
||||
final Uri baseEndpoint;
|
||||
String authorizationHeader = '';
|
||||
String acceptHeader = '';
|
||||
String requestPath = '';
|
||||
String requestBody = '';
|
||||
final List<String> requestBodies = <String>[];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user