Git Product home page Git Product logo

h2c's Introduction

h2c - A Simple HTTP/2 Command-Line Client

h2c is a simple HTTP/2 command-line client, like curl.

While curl terminates after each request/response cycle, h2c runs a background process to keep connections open. That way, h2c may receive asynchronous push messages from the server.

h2c is currently in a very early stage. The best way to learn about it is to read the blog posts on unrestful.io.

Screenshots

h2c dump

h2c command line

Basic Usage

h2c start &
h2c connect http2.akamai.com
h2c get /index.html
h2c stop

Command Overview

For a complete list of available commands, run h2c --help.

  • h2c start [options] Start the h2c process. The h2c process must be started before running any other command.
  • h2c connect [options] <host>:<port> Connect to a server using https
  • h2c disconnect Disconnect from server
  • h2c get [options] <path> Perform a GET request
  • h2c post [options] <path> Perform a POST request
  • h2c set <header-name> <header-value> Set a header. The header will be valid for all subsequent requests.
  • h2c unset <header-name> [<header-value>] Undo 'h2c set'.
  • h2c ping Send a ping.
  • h2c pid Show the process id of the h2c process.
  • h2c push-list List responses that are available as push promises.
  • h2c stream-info List streams and their states.
  • h2c stop Stop the h2c process
  • h2c wiretap <localhost:port> <remotehost:port> Listen on localhost:port and forward all traffic to remotehost:port.

How to Download and Run

Binary releases are available on the GitHub Releases.

  1. Download the latest release ZIP file: h2c-v0.0.12.zip
  2. Extract the ZIP file
  3. Find the executable for your system in the bin folder:
  • Linux: h2c_linux_amd64
  • OS X: h2c_darwin_amd64
  • Windows: h2c_windows_amd64.exe
  1. Rename that executable to h2c, or h2c.exe on Windows
  2. Move the executable into a folder on your PATH.

How to Build from Source

h2c is developed with Go 1.6. The external dependencies are located in the vendor/ directory. In Go 1.6, the vendor/ directory will be used by default. In order to build h2c with Go 1.5, you must enable the Go 1.5 vendor handling by setting the environment variable GO15VENDOREXPERIMENT to 1.

The following command will download, compile, and install h2c:

go get github.com/fstab/h2c

Related Work

h2c uses parts of Brad Fitzpatrick's HTTP/2 support for Go. There is an HTTP/2 console debugger included in bradfitz/http2, but just like h2c, it is currently only a quick few hour hack, so it is hard to tell if they aim at the same kind of tool.

LICENSE

h2c is licensed under the Apache License, Version 2.0.

h2c is implemented in Go and uses Go's standard library, which is licensed under Google's Go license, which is a variant of the BSD License.

The following 3rd party libraries are used:

h2c's People

Contributors

dave-r12 avatar fstab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

h2c's Issues

send request which is saved in a text file

i need to see what exactly I am sending or receiving using cli where the request header is saved in a txt file.

I can do something like the following to send request (which is saved in raw-http.txt) and get response using openssl.

% echo '"'; cat raw-http.txt; echo '"'
"
GET / HTTP/1.0
Host: www.google.com

"
% cat raw-http.txt | openssl s_client -quiet -connect www.google.com:443 2>/dev/null

Can h2c be used for that?

Another question. http/2 headers are encoded using hpack. suppose my raw-http2.txt looks like:

:method:GET
:path:/
:scheme:https
:authority:www.google.com
user-agent:curl/7.58.0
accept:*/*

So, i think i have to do something like:

% cat raw-http2.txt | encode-request | openssl s_client -quiet -connect www.google.com:443 2>/dev/null

can I do it using h2c?

Always receiving REFUSED_STREAM when sending PUSH_PROMISE

Example:

-> HEADERS(1)
- END_STREAM
+ END_HEADERS
:method: POST
:scheme: https
:authority: localhost:8443
:path: /
content-type: application/json
content-length: 58

Stream: RemainingSendFlowControlWindowIsEnough(58): 65535 > 58 = true
-> DATA(1)
+ END_STREAM
{58 bytes}

<- PUSH_PROMISE(1)
+ END_HEADERS
Promised Stream Id: 2
:authority: localhost:8443
:path: /

-> RST_STREAM(2)
Error code: REFUSED_STREAM

<- HEADERS(2)
- END_STREAM
+ END_HEADERS
:status: 400

<- DATA(2)
+ END_STREAM
{73 bytes}

Any thoughts on what's going on here?

Add possibility to check current status

It would be nice to have some command that displays info about current options set so user can double check is everything prepared correctly before sending request.

eg
command: h2c check-options
output:

connection: 123.123.123.123 
headers: 
  <Header1> : <value1> 
  <Header2> : <value2> 
data:  {} 
....

wiretap is broken

The cert that is baked into wiretap has expired.

        Validity
            Not Before: Aug 14 21:07:58 2015 GMT
            Not After : Sep 13 21:07:58 2015 GMT
        Subject: C=DE, ST=Some-State, O=h2c, CN=localhost

I would update it but it doesn't seem like this project is being maintained.

HTTP/2 without TLS does not work

For debugging, it would be useful if h2c also supported raw HTTP/2 without first establishing a TLS channel.
This is currently not possible, h2c will just fail.

Could you add this with an additional command line option or a fallback?

Disconnected without knowing it

I am using h2c version v0.0.10-SNAPSHOT build date 2015-12-28 on a Debian 8, up-to-date.

After connecting to a server (ex : www.google.com:443) and having submitted one request, if I don't submit other request to the server, I have the following error in the console with "h2c start --dump" :

Connection closed: Server sent GOAWAY with error code NO_ERROR
Error while reading next frame: EOF

Then, when I try to submit any other request, I have the following error message :

Not connected. Run 'h2c connect' first.

And if I try to disconnect from the server, I haven't any message. If I try to reconnect to the server, I have the following message :

Already connected to www.google.com:443

I am not sure if it is the right to report this kind of "bug", so let me know if i have to move it elsewhere.

Add --version flag

h2c is in a very early stage and will be refactored a lot.

It should have a --version flag so that future scripts can learn the available h2c version.

The output should have a form that will be consistent with any future development.

Error connecting to some Sites

Hi,

while the demo from README.md works with akamai, it does not work with some other sites:

$ h2c start &
$ h2c connect www.diplo.de:443
Error while reading next frame: Unknown setting in SETTINGS frame.
h2c get /index.html
Not connected. Run 'h2c connect' first.

h2c start --dump says:

[signal 0xb code=0x1 addr=0x30 pc=0x4b83f3]

goroutine 19 [running]:
panic(0x6e67a0, 0xc82000e130)
	/usr/local/go/src/runtime/panic.go:481 +0x3e6
github.com/fstab/h2c/cli/daemon.makeFrameFilter.func1(0x0, 0x0, 0x0, 0x0)
	/go/src/github.com/fstab/h2c/cli/daemon/daemon.go:51 +0x43
github.com/fstab/h2c/http2client/internal/connection.(*connection).ReadNextFrame(0xc820130420, 0x0, 0x0, 0x0, 0x0)
	/go/src/github.com/fstab/h2c/http2client/internal/connection/connection.go:469 +0x4e0
github.com/fstab/h2c/http2client/internal/eventloop.Start.func2(0x7f5f3a785820, 0xc820130420, 0xc82011d808, 0xc82008c1e0)
	/go/src/github.com/fstab/h2c/http2client/internal/eventloop/loop.go:82 +0x39
created by github.com/fstab/h2c/http2client/internal/eventloop.Start
	/go/src/github.com/fstab/h2c/http2client/internal/eventloop/loop.go:95 +0x37e

Cannot start h2c on Windows

The current version of h2c uses 'unix' sockets, which are not supported on Windows.

This should be fixed, so that h2c runs an all major operating systems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.