Skip to content

Commit

Permalink
grpcClient.finishSend() is essential for websocket transport (improba…
Browse files Browse the repository at this point in the history
…ble-eng#211)

* grpcClient.finishSend() is essential for websocket transport

* call hackIntoNormalGrpcRequest() in handleWebSocket()
  • Loading branch information
met-pub authored and MarcusLongmuir committed Aug 15, 2018
1 parent 2cf3019 commit e3d8d34
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
6 changes: 1 addition & 5 deletions go/grpcweb/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,8 @@ func (w *WrappedGrpcServer) handleWebSocket(wsConn *websocket.Conn, req *http.Re
req.Body = wrappedReader
req.Method = http.MethodPost
req.Header = headers
req.ProtoMajor = 2
req.ProtoMinor = 0
contentType := req.Header.Get("content-type")
req.Header.Set("content-type", strings.Replace(contentType, "application/grpc-web", "application/grpc", 1))

w.server.ServeHTTP(respWriter, req)
w.server.ServeHTTP(respWriter, hackIntoNormalGrpcRequest(req))
}

// IsGrpcWebRequest determines if a request is a gRPC-Web request by checking that the "content-type" is
Expand Down
1 change: 1 addition & 0 deletions ts/src/invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function invoke<TRequest extends ProtobufMessage, TResponse extends Proto

grpcClient.start(props.metadata);
grpcClient.send(props.request);
grpcClient.finishSend();

return {
close: () => {
Expand Down
1 change: 1 addition & 0 deletions ts/src/unary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function unary<TRequest extends ProtobufMessage, TResponse extends Protob

grpcClient.start(props.metadata);
grpcClient.send(props.request);
grpcClient.finishSend();

return {
close: () => {
Expand Down

0 comments on commit e3d8d34

Please sign in to comment.