Skip to content

ServeHTTP should support HTTP2 / vanilla gRPC #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
philipithomas opened this issue Jun 28, 2017 · 5 comments
Closed

ServeHTTP should support HTTP2 / vanilla gRPC #63

philipithomas opened this issue Jun 28, 2017 · 5 comments
Labels

Comments

@philipithomas
Copy link
Contributor

It looks like the Serve HTTP does not currently support vanilla HTTP2 gRPC requests.

I propose changing the ServeHTTP to check defer to grpcServer.ServeHTTP when the request is HTTP2.

It should look something like this:

func (w *WrappedGrpcServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
	if r.ProtoMajor == 2 && strings.Contains(r.Header.Get("Content-Type"), "application/grpc") {
			w.grpcServer.ServeHTTP(w, r)
        } else if w.IsAcceptableGrpcCorsRequest(req) || w.IsGrpcWebRequest(req) {
		w.corsWrapper.Handler(http.HandlerFunc(w.HandleGrpcWebRequest)).ServeHTTP(resp, req)
		return
	}
	w.server.ServeHTTP(resp, req)
}

(source parent)

So - is this approach ok? If I code it, will it get merged?

@MarcusLongmuir
Copy link
Contributor

@philipithomas: This makes sense. Can you open a PR please?

@johanbrandhorst
Copy link
Contributor

This issue confuses me a little, as w.grpcServer is currently not a field on the wrapper? I was going to suggest something similar to this but instead changing the parameter to the WrapServer method to a http.Handler to make it more composable. The restriction on a *grpc.Server type means you can't chain handlers easily with the wrapper. I think this would solve both these problems by letting th user define this handling themselves, if they wish, and passing that handler into the wrapper.

@johanbrandhorst
Copy link
Contributor

I've opened #81 which contains the suggested change.

@easyCZ
Copy link
Contributor

easyCZ commented Feb 18, 2018

Stale. Closing.

@easyCZ easyCZ closed this as completed Feb 18, 2018
easyCZ pushed a commit that referenced this issue Jan 31, 2019
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

If you make any changes to it yourself then they will take precedence over the rebase.

---

[//]: # (dependabot-end)

Bumps [browserstack-local](https://github.com/browserstack/browserstack-local-nodejs) from 1.3.4 to 1.3.7.
<details>
<summary>Release notes</summary>

*Sourced from [browserstack-local's releases](https://github.com/browserstack/browserstack-local-nodejs/releases).*

> ## Locked ps-tree version to 1.1.1
> This library has a dependency on ps-tree, which has a dependency on event-stream which had a security bug in newer versions.
> Hence locked ps-tree's version to 1.1.1 which uses event-stream's secure version 3.3.4
> 
> For more details, please refer:
> indexzero/ps-tree#33
> dominictarr/event-stream#116
> 
> ## Changed local binary paths to support LocalBinary 7.3. Fixed folder argument.
> Changed local binary paths to support LocalBinary 7.3. 
> Fixed folder argument when building browserstack local arguments.
</details>
<details>
<summary>Commits</summary>

- [`230ec93`](browserstack/browserstack-local-nodejs@230ec93) Merge pull request [#66](https://github-redirect.dependabot.com/browserstack/browserstack-local-nodejs/issues/66) from punitx/lock_ps_tree_version
- [`2c74310`](browserstack/browserstack-local-nodejs@2c74310) Bumped package version to 1.3.7
- [`0c5043f`](browserstack/browserstack-local-nodejs@0c5043f) Locked ps-tree version to 1.1.1
- [`e1f22d5`](browserstack/browserstack-local-nodejs@e1f22d5) Revert "Merge pull request [#65](https://github-redirect.dependabot.com/browserstack/browserstack-local-nodejs/issues/65) from yohan-pereira/remove_pstree"
- [`dfea668`](browserstack/browserstack-local-nodejs@dfea668) Merge pull request [#65](https://github-redirect.dependabot.com/browserstack/browserstack-local-nodejs/issues/65) from yohan-pereira/remove_pstree
- [`caf72de`](browserstack/browserstack-local-nodejs@caf72de) Revert "Overriding stop method for fixing stop local issue in docker [#56](https://github-redirect.dependabot.com/browserstack/browserstack-local-nodejs/issues/56)"
- [`5fec9d5`](browserstack/browserstack-local-nodejs@5fec9d5) Merge pull request [#63](https://github-redirect.dependabot.com/browserstack/browserstack-local-nodejs/issues/63) from browserstack/version_bump
- [`f03131c`](browserstack/browserstack-local-nodejs@f03131c) Version Bump
- [`ad3e3de`](browserstack/browserstack-local-nodejs@ad3e3de) Merge pull request [#62](https://github-redirect.dependabot.com/browserstack/browserstack-local-nodejs/issues/62) from browserstack/fix-folder-flg
- [`5a5a32a`](browserstack/browserstack-local-nodejs@5a5a32a) Fix argument order sent via command line to browserstack local binary.
- Additional commits viewable in [compare view](browserstack/browserstack-local-nodejs@v1.3.4...1.3.7)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=browserstack-local&package-manager=npm_and_yarn&previous-version=1.3.4&new-version=1.3.7)](https://dependabot.com/compatibility-score.html?dependency-name=browserstack-local&package-manager=npm_and_yarn&previous-version=1.3.4&new-version=1.3.7)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
Dependabot will merge this PR once it's up-to-date and CI passes on it, as requested by @easyCZ.

[//]: # (dependabot-automerge-end)

---

**Note:** This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

You can always request more updates by clicking `Bump now` in your [Dependabot dashboard](https://app.dependabot.com).

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>
@frederikhors
Copy link

@MarcusLongmuir maybe we should reopen this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants