Skip to content

Commit

Permalink
update: upgrade web package to v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
minoic committed Sep 27, 2024
1 parent 4621ac7 commit 2cda92b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
## 4.0.1
## 4.0.2-wip

* Internal optimization to client code.
* Small fixes, such as ports in testing and enabling `timeline_test.dart`.
* When the keep alive manager runs into a timeout, it will finish the transport instead of closing
the connection, as defined in the gRPC spec.
* Update xhr transport to migrate off legacy JS/HTML apis.

## 4.0.1

* Fix header and trailing not completing if the call is terminated. Fixes [#727](https://github.com/grpc/grpc-dart/issues/727)

## 4.0.0

* Set compressed flag correctly for grpc-encoding = identity. Fixes [#669](https://github.com/grpc/grpc-dart/issues/669) (https://github.com/grpc/grpc-dart/pull/693)
Expand Down
33 changes: 10 additions & 23 deletions lib/src/client/transport/xhr_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ class XhrTransportStream implements GrpcTransportStream {
if (_incomingProcessor.isClosed) {
return;
}
// TODO: dart-lang/web#285 use 'if' for now
if (_request.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
_onHeadersReceived();
} else if (_request.readyState == XMLHttpRequest.DONE) {
_onRequestDone();
_close();
switch (_request.readyState) {
case XMLHttpRequest.HEADERS_RECEIVED:
_onHeadersReceived();
break;
case XMLHttpRequest.DONE:
_onRequestDone();
_close();
break;
}
});

Expand Down Expand Up @@ -99,7 +101,7 @@ class XhrTransportStream implements GrpcTransportStream {
bool _validateResponseState() {
try {
validateHttpStatusAndContentType(
_request.status, _parseHeaders(_request.getAllResponseHeaders()),
_request.status, _request.responseHeaders,
rawResponse: _request.responseText);
return true;
} catch (e, st) {
Expand All @@ -113,8 +115,7 @@ class XhrTransportStream implements GrpcTransportStream {
if (!_validateResponseState()) {
return;
}
_incomingMessages
.add(GrpcMetadata(_parseHeaders(_request.getAllResponseHeaders())));
_incomingMessages.add(GrpcMetadata(_request.responseHeaders));
}

void _onRequestDone() {
Expand All @@ -138,20 +139,6 @@ class XhrTransportStream implements GrpcTransportStream {
_onDone(this);
}

Map<String, String> _parseHeaders(String rawHeaders) {
final headers = <String, String>{};
final lines = rawHeaders.split('\r\n');
for (var line in lines) {
final index = line.indexOf(': ');
if (index != -1) {
final key = line.substring(0, index);
final value = line.substring(index + 2);
headers[key] = value;
}
}
return headers;
}

@override
Future<void> terminate() async {
_close();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
http2: ^2.2.0
protobuf: '>=2.0.0 <4.0.0'
clock: ^1.1.1
web: ^1.0.0
web: ^1.1.0

dev_dependencies:
build_runner: ^2.0.0
Expand Down

0 comments on commit 2cda92b

Please sign in to comment.