mirror of https://github.com/grpc/grpc-dart.git
Encode server error message (#330)
This commit is contained in:
parent
98ff843751
commit
e4947e2909
|
|
@ -293,7 +293,8 @@ class ServerHandler_ extends ServiceCall {
|
||||||
_customTrailers = null;
|
_customTrailers = null;
|
||||||
outgoingTrailersMap['grpc-status'] = status.toString();
|
outgoingTrailersMap['grpc-status'] = status.toString();
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
outgoingTrailersMap['grpc-message'] = message;
|
outgoingTrailersMap['grpc-message'] =
|
||||||
|
Uri.encodeFull(message).replaceAll("%20", " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
final outgoingTrailers = <Header>[];
|
final outgoingTrailers = <Header>[];
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,20 @@ void main() {
|
||||||
await harness.fromServer.done;
|
await harness.fromServer.done;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Server returns encoded error for unary call', () async {
|
||||||
|
Future<int> methodHandler(ServiceCall call, Future<int> request) async {
|
||||||
|
throw GrpcError.unknown("エラー");
|
||||||
|
}
|
||||||
|
|
||||||
|
harness
|
||||||
|
..service.unaryHandler = methodHandler
|
||||||
|
..expectErrorResponse(StatusCode.unknown, '%E3%82%A8%E3%83%A9%E3%83%BC')
|
||||||
|
..sendRequestHeader('/Test/Unary')
|
||||||
|
..sendData(dummyValue)
|
||||||
|
..toServer.close();
|
||||||
|
await harness.fromServer.done;
|
||||||
|
});
|
||||||
|
|
||||||
test('Server returns error if multiple headers are received for unary call',
|
test('Server returns error if multiple headers are received for unary call',
|
||||||
() async {
|
() async {
|
||||||
harness
|
harness
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue