Skip to content

Commit

Permalink
Merge pull request #1 from a-elhusseine/master
Browse files Browse the repository at this point in the history
El Peso G / grpc-web
  • Loading branch information
Gregg Juan Eduardo Palomo Herrera authored Aug 23, 2020
2 parents 01ed706 + ec4d148 commit 919558c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
6 changes: 4 additions & 2 deletions BROWSER-FEATURES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gRPC-Web features for browser (HTML) clients

Due to browser limitation, gRPC-Web supports a different transport
Due to browser limitation, gRPC-Web uses a different transport
than the [HTTP/2 based gRPC protocol](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md).
The difference between the gRPC-Web
protocol and the HTTP/2 based gRPC protocol is specified in the core gRPC repo as [PROTOCOL-WEB](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md).
Expand All @@ -9,9 +9,11 @@ In addition to the wire-transport spec, gRPC-Web also supports features that are
This document is the official spec for those features. As the Web platform evolves,
we expect some of those features will evolve too or become deprecated.

On the server-side, [Envoy](https://www.envoyproxy.io/) is the official proxy with out-of-box gRPC-Web support. New features will be implemented in Envoy first. For [in-process gRPC-Web support](https://github.com/grpc/grpc-web/blob/master/IN-PROCESS-PROXY.md), we recommend the gRPC-Web module implement only a minimum set of features, e.g. to enable local development. Those features are identified as mandatory features in this doc.

# CORS support

* Should follow the [CORS spec](https://developer.mozilla.org/en-US/docs/Web/HTTP/Server-Side_Access_Control)
* Should follow the [CORS spec](https://developer.mozilla.org/en-US/docs/Web/HTTP/Server-Side_Access_Control) (Mandatory)
* Access-Control-Allow-Credentials to allow Authorization headers
* Access-Control-Allow-Methods to allow POST and (preflight) OPTIONS only
* Access-Control-Allow-Headers to whatever the preflight request carries
Expand Down
30 changes: 30 additions & 0 deletions IN-PROCESS-PROXY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Overview

In-process proxies allow a browser client to talk to the gRPC server directly without deploying any intermediary process
such as an Envoy proxy. This document provides a high-level design guidelines on how we expect such a "proxy" to work.

# The choice of HTTP stack

We strongly recommend the gRPC-Web module use the default HTTP stack provided by the language platform, or in the case of Java,
the standard Java Servlet stack. This is to ensure maximum portability and to ease integration between gRPC-Web and existing Web
frameworks.

The actual HTTP version that the HTTP stack supports may include both HTTP/1.1 and HTTP/2. In the runtime, it's up to the user-agent and
intermediaries to negotiate the HTTP version, which is mostly transparent to the gRPC-Web module.

# Proxy or not

For most languages, the gRPC-Web module will handle the gRPC-Web request, do the translation, and then proxy the request using a gPRP client
to the gRPC server via a local socket. The gRPC-Web support is totally transparent to the gRPC server.

For some languages, such as Swift, if the gRPC server implementation uses the same HTTP stack as gRPC-Web, then gRPC-Web may be supported
directly as part of the gRPC server implementation. The added complexity to the gRPC iteslf is still a concern.

# HTTP port

We expect that gRPC-Web requests are handled on a separate port. If the HTTP stack supports both HTTP/2 and HTTP/1.1, port sharing could be supported.
However, since CORS is a mandatory feature for gRPC-Web proxies, porting sharing is optional for in-process proxies.




2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Do you need request compression? Brotli?
## CORS

We plan to support CORS preflight as specified in
[PROTOCOL-WEB.md](https://github.com/grpc/grpc-web/blob/master/PROTOCOL-WEB.md).
[PROTOCOL-WEB.md](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md).

## Local Proxies

Expand Down
8 changes: 5 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
workspace(name = "com_github_grpc_grpc_web")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_closure",
sha256 = "a8ea3251a6fd05eb3dbd05aa443a12b04cb88d80480d821bee453b18db97afaa",
strip_prefix = "rules_closure-8ec740d0b77ca1fb4914c857dc67ccc3f9cb3ed4",
sha256 = "3098d87bb0b5be7399b402da45b360b07a401bbd6d2b0033b0c16c4d060f4d01",
strip_prefix = "rules_closure-d1110778a2e94bcdac5d5d00044dcb6cd07f1d51",
urls = [
"https://github.com/bazelbuild/rules_closure/archive/8ec740d0b77ca1fb4914c857dc67ccc3f9cb3ed4.zip",
"https://github.com/bazelbuild/rules_closure/archive/d1110778a2e94bcdac5d5d00044dcb6cd07f1d51.zip",
],
)

Expand Down
2 changes: 1 addition & 1 deletion scripts/kokoro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ done
docker-compose -f advanced.yml build

# Run all bazel unit tests
BAZEL_VERSION=0.19.1
BAZEL_VERSION=0.22.0
wget https://github.com/bazelbuild/bazel/releases/download/"${BAZEL_VERSION}"/bazel-"${BAZEL_VERSION}"-installer-linux-x86_64.sh
chmod +x ./bazel-"${BAZEL_VERSION}"-installer-linux-x86_64.sh
./bazel-"${BAZEL_VERSION}"-installer-linux-x86_64.sh --user
Expand Down

0 comments on commit 919558c

Please sign in to comment.