h2c | HTTP/2 Cleartext Wrappers | HTTP library

 by   carl-mastrangelo Go Version: Current License: Apache-2.0

kandi X-RAY | h2c Summary

kandi X-RAY | h2c Summary

h2c is a Go library typically used in Networking, HTTP applications. h2c has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

By default, the Go HTTP Server only handles HTTP/2 connections over TLS as hinted by RFC 7540. This is good for the security of the Internet, but makes things cumbersome when proxying requests over an already secure connection (such as in-memory unit tests, Unix Domain Sockets, local TCP connections, etc.).
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              h2c has a low active ecosystem.
              It has 8 star(s) with 0 fork(s). There are no watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              h2c has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of h2c is current.

            kandi-Quality Quality

              h2c has no bugs reported.

            kandi-Security Security

              h2c has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              h2c is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              h2c releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed h2c and discovered the below as its top functions. This is intended to give you an instant insight into h2c implemented functionality, and help decide if they suit your requirements.
            • RoundTrip implements the http . RoundTripper interface .
            • start the H2c client
            • startServer starts the server
            • startProxy starts the http proxy
            • NewClearTextTransport wraps http . RoundTripper with an http2Fallback .
            • startH2BackendServer starts the H2c backend server .
            • startBackendServer starts the HTTP server .
            • startH1BackendServer starts the HTTP server .
            • newH2ForwardConn returns a new h2ForwardConn .
            • NewClearTextHandler returns a new http2 handler which wraps h2 s2 s2 and delegates to h2 s2 .
            Get all kandi verified functions for this library.

            h2c Key Features

            No Key Features are available at this moment for h2c.

            h2c Examples and Code Snippets

            No Code Snippets are available at this moment for h2c.

            Community Discussions

            QUESTION

            Dealing with OkHttp HTTP/2 REFUSED_STREAM errors
            Asked 2021-Jun-08 at 13:43

            We are Using OkHttp3 (v4.9.1) to establish h2c (HTTP/2 without TLS) connections in a highly concurrent fashion from a Spring Boot application. To do so, we have narrowed down the supported protocols using:

            ...

            ANSWER

            Answered 2021-Jun-08 at 11:34

            With this issue you've made the case for us to fix it in OkHttp. https://github.com/square/okhttp/issues/6700

            In the interim, you'll want an interceptor that uses a try/catch block, and attempts again in the catch clause if the exception matches this criteria.

            Source https://stackoverflow.com/questions/67883227

            QUESTION

            Why does the HTTP Upgrade: header contain both h2 and h2c in Apache?
            Asked 2021-May-18 at 10:23

            Why does the HTTP Upgrade: header contain both h2 and h2c in Apache?

            I think you can only run the HTTP/2 clear text variant, (h2c).

            Why does it also include the options h2? Since it is only going to be accessed from TLS, right?

            Edit, final question:

            Over HTTP, Apache ignores request to upgrade to h2, but it usually advertises it.

            ...

            ANSWER

            Answered 2021-May-18 at 10:23

            Because you can upgrade to h2 or h2c. Yes the former would be negotiated automatically if you used HTTPS initially, but if you didn’t then it’s valid to say you can use h2 if you do switch to that. You could also send back a 301/302 redirect which would effectively redirect you to HTTPS and so h2 but since the upgrade mechanism is not used by browsers maybe you can’t assume the sending application will use those?

            A bigger question to me is why the upgrade mechanism exists at all! As I think you’re implying, if you can talk HTTPS then you’ll be using HTTP/2 if you can and so don’t need the upgrade mechanism. And the reason browsers only support HTTP/2 over HTTPS is its so unreliable over HTTP as middleboxes assume HTTP/1 - which means the only use of h2c is for non-browser communication where you’re basically in control of the end to end connection so can skip the upgrade dance and go straight the h2c (aka the “prior knowledge” method of using HTTP/2). The preface message can always be used to reject and/or fallback to HTTP/1 if a client unexpectedly doesn’t support HTTP/2.

            In the meantime the upgrade mechanism does cause real problems. For example nginx used to blindly forward this on even if it was already using HTTP/2 to the client. So if a backend Apache server saw the nginx connection was HTTP/1.1 and then suggested HTTP/2 then nginx forward that on to the browser which gets confused as it’s already talking HTTP/2 (to nginx). Safari used to handle this really badly and break and refuse to display the site basically. Yes maybe if Apache hadn’t suggested h2 in the upgrade header this wouldn’t have happened (is that where your question stems from?) but technically it’s nginx at fault here. I can’t remember if they fixed this but think they did.

            Anyway, this has been recognised by the HTTP Working Group and they are likely to remove the upgrade mechanism for the next update to the HTTP/2 spec.

            While we’re at it, I do wonder if there’s much use for h2c? Obviously the browsers not supporting it puts a severe dent in its usage but, as I say, that was go good reason. Is it used much in non-browser contexts? Difficult to say and even if it is would the requirement to use HTTPS be that much of an extra burden and/or be more reliable?

            Edit: to answer your further questions.

            Yes all of that is correct.

            Case 1: You cannot use h2 of HTTP so it cannot be used via the upgrade header. It’s arguable whether h2 should be in the upgrade header for this reasons and, as you point out, it’s not listed in the IANA registry of allowed upgrade headers. My understanding is this is for upgrading a connection over the same transport protocol and while h2 would still be over HTTP over TCP, so technically over the same transport protocol, it does need HTTP so does need a new connection (and usually different port) so definitely stretching the definition of upgrade!

            Case 2: Yes this is what should happen.

            Case 3: Arguable but I think technically correct. I’d call that a downgrade rather than an upgrade, but the upgrade mechanism is really a “I support different protocols you might prefer” mechanism rather necessarily an “upgrade to a better protocol” header. Similar to case 1 this will likely require a new connection so again it’s arguable whether this really fits in with the upgrade mechanism as it was intended to be used.

            As I say all this is fairly irrelevant, or will be soon, as it will be removed from the HTTP/2 spec.

            Source https://stackoverflow.com/questions/67583138

            QUESTION

            How to get all effective HTTP request headers?
            Asked 2021-May-17 at 13:38

            I want to use the new java.net.HttpClient to do some requests to another system.

            For debug purposes I want to log (and later store in our db) the request that I send and the response that I receive.

            How can I retrieve the effective http headers, that java is sending?

            I tried to get the headers like this:

            ...

            ANSWER

            Answered 2021-May-17 at 13:38

            I have an unfortunate answer to your question: Regrettably, impossible.

            Some background on why this is the case:

            The actual implementation of HttpRequest used by your average OpenJDK-based java-core-library implementation is not java.net.http.HttpRequest - that is merely an interface. It's jdk.internal.net.http.HttpRequestImpl.

            This code has 2 separate lists of headers to send; one is the 'user headers' and the other is the 'system headers'. Your .headers() call retrieves solely the user headers, which are headers you explicitly asked to send, and, naturally, as you asked for none to send, it is empty.

            The system headers is where those 6 headers are coming from. I don't think there is a way to get at these in a supported fashion. If you want to dip into unsupported strategies (Where you write code that queries internal state and is thus has no guarantee to work on other JVM implementations, or a future version of a basic JVM implementation), it's still quite difficult, unfortunately! Some basic reflection isn't going to get the job done here. It's the worst news imaginable:

            • These 6 headers just aren't set, at all, until send is invoked. For example, the three headers that are HTTP2 related are set in the package-private setH2Upgrade method, and this method is passed the HttpClient object, which proves that this cannot possibly be called except in the chain of events started when you invoke send. An HttpClient object doesn't exist in the chain of code that makes HttpRequest objects, which proves this.

            • To make matters considerably worse, the default HttpClient impl will first clone your HttpRequest, then does a bunch of ops on this clone (including adding those system headers), and then sends the clone, which means the HttpRequest object you have doesn't have any of these headers. Not even after the send call completes. So even if you are okay with fetching these headers after the send and are okay with using reflecting to dig into internal state to get em, it won't work.

            You also can't reflect into the client because the relevant state (the clone of your httprequest object) isn't in a field, it's in a local variable, and reflection can't get you those.

            A HttpRequest can be configured with custom proxies, which isn't much of a solution either: That's TCP/IP level proxies, not HTTP proxies, and headers are sent encrypted with HTTPS. Thus, writing code that (ab)uses the proxy settings so that you can make a 'proxy' that just bounces the connection around your own code first before sending it out, in order to see the headers in transit, is decidedly non-trivial.

            The only solution I can offer you is to ditch java.net.http.HttpClient entirely and use a non-java-lib-core library that does do what you want. perhaps OkHttp. (Before you sing hallelujah, I don't actually know if OkHttp can provide you with all the headers it intends to send, or give you a way to register a hook that is duly notified, so investigate that first!)

            Source https://stackoverflow.com/questions/67570348

            QUESTION

            trying to upgrade to http2 via python socket
            Asked 2021-Apr-03 at 00:12

            I am trying to upgrade to http/2.0 using a python socket. I have already tried using the upgrade header like so: Connection: Upgrade then Upgrade: h2c. This makes the server respond with a http/1.1 200 OK response. I am now trying to use ALPN via the ssl module.
            This is the code for attempting via ALPN:

            ...

            ANSWER

            Answered 2021-Apr-03 at 00:12

            I think some of your exception handling was giving you the wrong hints. If you encountered an exception, you'd have been trying to connect again, and at some point Windows complained about trying to connect to a socket that wasn't closed.

            The ALPN protocol for HTTP/2 should be set to h2, and after that running your code gave me an error:

            Source https://stackoverflow.com/questions/66926114

            QUESTION

            Trying to insert data from Swift into a MySQLi database using POST request via php
            Asked 2021-Mar-16 at 11:57

            To preface, I'm currently still learning Swift and just wanted to have a dabble at trying to send data to some kind of backend from within my app. Not sure if important but if so:

            • I am using fast comet as a web server with a PHPMyAdmin database in SQL. (struggling to get my head around it so that may be said incorrectly, apologies in advance!)

            From what I can gather (please say if I've got this backwards), the executions on the database are written in SQL which I have included in my fetch request for my app (working successfully). The PHP file acts as a bridge to open a connection between the database and my end.

            I've tried (semi-successfully) for 3 days to write a POST request in swift that will send the data from my app and insert it into my database. When I say semi-successfully, I mean that when triggering the inert method in my swift code from the app, data DOES get inserted into the database but it is the data on the alternative side of the nil-coalescing operator and not my data. This leads me to believe that all is (just about) okay with my .PHP file and that there is either a problem with my swift code, or that I've not set something up correctly within the database itself?

            database with table named "Students" - consists of 5 fields:

            • id : INT
            • first_name : TEXT
            • last_name : TEXT
            • subject : TEXT
            • grade : INT

            swift - what I'm trying to insert into the database:

            • id : Int
            • firstName : String
            • lastName : String
            • subject : String
            • grade : Int

            swift code:

            ...

            ANSWER

            Answered 2021-Mar-16 at 11:57

            You are not executing your query in the PHP code, try to edit your code like this:

            Source https://stackoverflow.com/questions/66642212

            QUESTION

            Setup Quart server with HTTP/2
            Asked 2021-Mar-02 at 18:21

            I am trying to setup a Quart server to play with HTTP/2. I have been trying to go through the minimal documentation at:

            Where I have:

            ...

            ANSWER

            Answered 2021-Mar-02 at 18:21

            Locally you are upgrading an insecure HTTP 1.1 request to an insecure HTTP 2 request. This works with Quart and curl, but browsers including chrome do not support insecure (unencrypted) HTTP/2. For it to work in chrome I create a self signed certificate, passing the certfile and keyfile options to the run and accept the warning chrome offers when visiting the site. An example exists here.

            Source https://stackoverflow.com/questions/66437195

            QUESTION

            Unable to call grpc server hosted behind traefik reverse proxy
            Asked 2021-Jan-07 at 17:37

            I am facing a weird issue where I am unable to call gRPC server hosted behind traefik proxy running in a container with http/2 and a custom subdomain from asp.net 5 app also hosted in another container with another domain name mapped to it. I am getting the below error:

            ...

            ANSWER

            Answered 2021-Jan-07 at 13:30

            It was just a stupid firewall issue that was blocking container out @ 443

            Source https://stackoverflow.com/questions/65607793

            QUESTION

            (questions about POST requests) Is there a way to send a POST request and then get back the retrieved resource in the event of a 302 externally?
            Asked 2020-Dec-06 at 23:02

            This is a bit confusing but I'm going to try my best to explain it properly, I'll really appreciate an answer to this.

            Suppose I've got the endpoint "example.com/login" that displays an HTML page with a login form that upon submitting sends a POST request to "example.com/login" (yes itself) with the credentials (shown below) and then upon successful authentication displays another HTML page (example.com/user/records) that shows your details (for e.g your data records and stuff).

            What I plan on doing is accessing the HTML page that shows that data by sending a POST request externally using Javascript with the credentials and then somehow just receiving the HTML for the data records page as a string response as we'd normally get through a GET request (is this even possible?).

            upon sending said request it shows this in the network tab: (Remote Address has been modified to replace all numbers with 0)

            ...

            ANSWER

            Answered 2020-Dec-06 at 23:02

            I realized it could be solved in some cases providing "redirect": "follow" to the JSON when using a Node fetch request.

            Source https://stackoverflow.com/questions/65082521

            QUESTION

            Artifactory Crash due to Segmentation Violation
            Asked 2020-Nov-12 at 08:41

            We are running Artifactory OSS 7.4.3 in a couple environments, all Linux (RHEL 7). They are using local repositories with standard downloads/uploads of Maven artifacts. Two of those environments have encountered a "segmentation violation" error in the past few weeks. I have not been able to find any documentation of this error occurring during regular operation. My question is how should I go about troubleshooting the error?

            ...

            ANSWER

            Answered 2020-Nov-12 at 08:41

            This is due to a bug in the Go runtime used at that time (1.14.2), for more details see https://groups.google.com/g/golang-announce/c/XZNfaiwgt2w/m/E6gHDs32AQAJ

            It's been fixed starting from Artifactory 7.7.0, so you can just upgrade to the latest release (7.10.6 when writing this message)

            Source https://stackoverflow.com/questions/64794592

            QUESTION

            Golang H2C Server doesn't write full body. Chrome says: "Server reset stream". Only occurs over http2 connection
            Asked 2020-Oct-27 at 16:51

            Most Recent Version of Go (1.153)

            Below is the code for reproducibility. Please try to access https://easy-dp.ngrok.io to see the issue.

            Here's what I did:

            1. Create a Reverse Proxy accessing Gzipped/ Br encoded Content
            2. Request a publicly available URL, I just grabbed Google Analytics
            3. Attempt to encode and decode the response via an http2 connection with a proxy.modifyresponse function
            4. Watch as content is dropped.

            However, this only occurs under the following conditions:

            • Under SSL, like with https://easy-dp.ngrok.io
            • When running a proxy.ModifyResponse function
            • Decompressing and re-compressing the body (for example, just reading and rewriting the body to new bytes works)
            ...

            ANSWER

            Answered 2020-Oct-27 at 16:51

            The Content-Length header indicates the size of the entity body in the message, in bytes. The size includes any content encodings (the Content-Length of a gzip-compressed text file will be the compressed size, not the original size).

            src

            I thought I had tried this but kept running into ERR_CONTENT_LENGTH_MISMATCH because of how I was closing my gzip writer. Related Question

            Final handler looked like this:

            Source https://stackoverflow.com/questions/64549194

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install h2c

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/carl-mastrangelo/h2c.git

          • CLI

            gh repo clone carl-mastrangelo/h2c

          • sshUrl

            git@github.com:carl-mastrangelo/h2c.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular HTTP Libraries

            requests

            by psf

            okhttp

            by square

            Alamofire

            by Alamofire

            wrk

            by wg

            mitmproxy

            by mitmproxy

            Try Top Libraries by carl-mastrangelo

            kvstore

            by carl-mastrangeloJava

            gammux

            by carl-mastrangeloGo

            pixur

            by carl-mastrangeloGo

            prefix

            by carl-mastrangeloJava

            fractals

            by carl-mastrangeloC