{"id":17470762,"url":"https://github.com/matsumotory/mruby-http2","last_synced_at":"2025-04-30T08:24:45.821Z","repository":{"id":12872106,"uuid":"15548481","full_name":"matsumotory/mruby-http2","owner":"matsumotory","description":"HTTP2 Module for mruby","archived":false,"fork":false,"pushed_at":"2019-04-05T07:53:51.000Z","size":1014,"stargazers_count":44,"open_issues_count":3,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T14:23:33.881Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matsumotory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-31T10:58:16.000Z","updated_at":"2023-11-20T07:30:46.000Z","dependencies_parsed_at":"2022-08-28T14:12:38.748Z","dependency_job_id":null,"html_url":"https://github.com/matsumotory/mruby-http2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsumotory%2Fmruby-http2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsumotory%2Fmruby-http2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsumotory%2Fmruby-http2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsumotory%2Fmruby-http2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matsumotory","download_url":"https://codeload.github.com/matsumotory/mruby-http2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251667550,"owners_count":21624521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-18T16:09:51.172Z","updated_at":"2025-04-30T08:24:45.799Z","avatar_url":"https://github.com/matsumotory.png","language":"C","readme":"# HTTP2 Module for mruby \n\n[![Build Status](https://travis-ci.org/matsumotory/mruby-http2.svg?branch=master)](https://travis-ci.org/matsumotory/mruby-http2)\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/trusterd/mruby-http2?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nHTTP2 module for mruby using [nghttp2](https://github.com/nghttp2/nghttp2). You can access Web site using HTTP/2 protocol from mruby applications or devices with mruby, and run HTTP/2 Web server easily.\n\n- [HTTP/2 Web Server by mruby-http2](https://github.com/matsumotory/mruby-http2/blob/master/README.md#http2server)\n- [HTTP/2 Client by mruby-http2](https://github.com/matsumotory/mruby-http2/blob/master/README.md#http2client)\n\n#### [HTTP/2](http://http2.github.io/) \n\nHTTP/2 is a replacement for how HTTP is expressed \"on the wire\". It is not a ground-up rewrite of the protocol; HTTP methods, status codes and semantics will be the same, and it should be possible to use the same APIs as HTTP/1.x (possibly with some small additions) to represent the protocol.\n\n## [Trusterd HTTP/2 Web Server](https://github.com/matsumotory/trusterd)\n[Trusterd](https://github.com/matsumotory/trusterd) is a HTTP/2 Web Server implementation using mruby-http2.\n\n## Benchmark\nPlease see [link](https://gist.github.com/matsumotory/9702123).\n\n## Development Environment\n\nRequrie: vagrant\n\n```\nvagrant up\nvagrant ssh\ncd mruby-http2\nrake test\n```\n\n## Install by mrbgems\n#### Download mruby\n```\ngit clone https://github.com/mruby/mruby.git\n```\n#### Add conf.gem line to `mruby/build_config.rb`\n```ruby\nMRuby::Build.new do |conf|\n\n  # ... (snip) ...\n\n  conf.gem :github =\u003e 'matsumotory/mruby-http2'\nend\n```\n\n#### build\n```\ncd mruby\nrake\n```\n\n## Example\n### mruby-http2 Test Site\n```\nhttps://http2.matsumoto-r.jp:58080/index.html\n```\n### HTTP2::Client\n##### HTTP2 get\nAccess to nghttpd HTTP/2 Server\n```ruby\nr = HTTP2::Client.get 'https://127.0.0.1:8080/index.html'\n\nr.response\nr.body\nr.request_headers\nr.response_headers\nr.status\nr.body\nr.body_length\nr.stream_id\n```\n##### HTTP2 get reuslt\n```ruby\n{:body=\u003e\"hello mruby-http2!!\\n\", :body_length=\u003e20, :recieve_bytes=\u003e20.0, :response_headers=\u003e{\"last-modified\"=\u003e\"Wed, 19 Mar 2014 08:41:00 GMT\", \"server\"=\u003e\"nghttpd nghttp2/0.4.0-DEV\", \":status\"=\u003e\"200\", \"date\"=\u003e\"Thu, 20 Mar 2014 11:38:17 GMT\", \"cache-control\"=\u003e\"max-age=3600\", \"content-length\"=\u003e\"20\"}, :frame_send_header_goway=\u003etrue, :request_headers=\u003e{\"user-agent\"=\u003e\"mruby-http2/0.0.1\", \"accept\"=\u003e\"*/*\", \":authority\"=\u003e\"127.0.0.1:8080\", \":scheme\"=\u003e\"https\", \"accept-encoding\"=\u003e\"gzip\", \":method\"=\u003e\"GET\", \":path\"=\u003e\"/index.html\"}, :stream_id=\u003e1}\n\"hello mruby-http2!!\\n\"\n{\"user-agent\"=\u003e\"mruby-http2/0.0.1\", \"accept\"=\u003e\"*/*\", \":authority\"=\u003e\"127.0.0.1:8080\", \":scheme\"=\u003e\"https\", \"accept-encoding\"=\u003e\"gzip\", \":method\"=\u003e\"GET\", \":path\"=\u003e\"/index.html\"}\n{\"last-modified\"=\u003e\"Wed, 19 Mar 2014 08:41:00 GMT\", \"server\"=\u003e\"nghttpd nghttp2/0.4.0-DEV\", \":status\"=\u003e\"200\", \"date\"=\u003e\"Thu, 20 Mar 2014 11:38:17 GMT\", \"cache-control\"=\u003e\"max-age=3600\", \"content-length\"=\u003e\"20\"}\n200\n\"hello mruby-http2!!\\n\"\n20\n1\n```\n##### Set callback block from Ruby\nAccess to nghttpd HTTP/2 Server\n```ruby\nr = HTTP2::Client.get 'https://127.0.0.1:8080/index.html'\n\np r.response\np r.body\np r.request_headers\np r.response_headers\np r.status\np r.body\np r.body_length\np r.stream_id\n\np \"---- set callback version ----\"\n\ns = HTTP2::Client.new\ns.uri = 'https://127.0.0.1:8080/index.html'\ns.on_header_callback {\n  p \"header callback\"\n}\ns.send_callback {\n  p \"send_callback\"\n}\ns.recv_callback {\n  p \"recv_callback\"\n}\ns.before_frame_send_callback {\n  p \"before_frame_send_callback\"\n}\ns.on_frame_send_callback {\n  p \"on_frame_send_callback\"\n}\ns.on_frame_recv_callback {\n  p \"on_frame_recv_callback\"\n}\ns.on_stream_close_callback {\n  p \"on_stream_close_callback\"\n}\ns.on_data_chunk_recv_callback {\n  p \"on_data_chunk_recv_callback\"\n}\nr = s.get\np r.response\n\n```\n##### Result\n```ruby\n\"---- set callback version ----\"\n\"recv_callback\"\n\"on_frame_recv_callback\"\n\"recv_callback\"\n\"before_frame_send_callback\"\n\"send_callback\"\n\"on_frame_send_callback\"\n\"before_frame_send_callback\"\n\"send_callback\"\n\"on_frame_send_callback\"\n\"recv_callback\"\n\"header callback\"\n\"header callback\"\n\"header callback\"\n\"header callback\"\n\"header callback\"\n\"header callback\"\n\"on_frame_recv_callback\"\n\"on_data_chunk_recv_callback\"\n\"on_frame_recv_callback\"\n\"on_frame_recv_callback\"\n\"on_stream_close_callback\"\n\"recv_callback\"\n\"before_frame_send_callback\"\n\"send_callback\"\n\"on_frame_send_callback\"\n{:body=\u003e\"hello mruby-http2!!\\n\", :body_length=\u003e20, :recieve_bytes=\u003e20.0, :response_headers=\u003e{\"last-modified\"=\u003e\"Wed, 19 Mar 2014 08:41:00 GMT\", \"server\"=\u003e\"nghttpd nghttp2/0.4.0-DEV\", \":status\"=\u003e\"200\", \"date\"=\u003e\"Thu, 20 Mar 2014 11:39:34 GMT\", \"cache-control\"=\u003e\"max-age=3600\", \"content-length\"=\u003e\"20\"}, :frame_send_header_goway=\u003etrue, :request_headers=\u003e{\"user-agent\"=\u003e\"mruby-http2/0.0.1\", \"accept\"=\u003e\"*/*\", \":authority\"=\u003e\"127.0.0.1:8080\", \":scheme\"=\u003e\"https\", \"accept-encoding\"=\u003e\"gzip\", \":method\"=\u003e\"GET\", \":path\"=\u003e\"/index.html\"}, :stream_id=\u003e1}\n```\n### HTTP2::Server\n##### run HTTP/2 server\n###### If you want to get more information, Please see [Trusterd HTTP/2 Web Server](https://github.com/trusterd/trusterd) using mruby-http2.\n```ruby\nroot_dir = \"/usr/local/trusterd\"\n\ns = HTTP2::Server.new({\n\n  :port           =\u003e 8080,\n  :document_root  =\u003e \"#{root_dir}/htdocs\",\n  :server_name    =\u003e \"mruby-http2 server\",\n\n  :key            =\u003e \"#{root_dir}/ssl/server.key\",\n  :crt            =\u003e \"#{root_dir}/ssl/server.crt\",\n\n})\n\ns.run\n```\n##### request from HTTP2::Client \n```ruby\nr = HTTP2::Client.get 'https://127.0.0.1:8080/index.html'\n\np r.response\np r.body\np r.request_headers\np r.response_headers\np r.status\np r.body\np r.body_length\np r.stream_id\n\np \"---- set callback version ----\"\n\ns = HTTP2::Client.new\ns.uri = 'https://127.0.0.1:8080/index.html'\ns.on_header_callback {\n  p \"header callback\"\n}\ns.send_callback {\n  p \"send_callback\"\n}\ns.recv_callback {\n  p \"recv_callback\"\n}\ns.before_frame_send_callback {\n  p \"before_frame_send_callback\"\n}\ns.on_frame_send_callback {\n  p \"on_frame_send_callback\"\n}\ns.on_frame_recv_callback {\n  p \"on_frame_recv_callback\"\n}\ns.on_stream_close_callback {\n  p \"on_stream_close_callback\"\n}\ns.on_data_chunk_recv_callback {\n  p \"on_data_chunk_recv_callback\"\n}\nr = s.get\np r.response\n```\n##### response\n```ruby\n{:body=\u003e\"hello mruby-http2!!\\n\", :body_length=\u003e20, :recieve_bytes=\u003e20.0, :response_headers=\u003e{\":status\"=\u003e\"200\"}, :frame_send_header_goway=\u003etrue, :request_headers=\u003e{\"user-agent\"=\u003e\"mruby-http2/0.0.1\", \"accept\"=\u003e\"*/*\", \":authority\"=\u003e\"127.0.0.1:8080\", \":scheme\"=\u003e\"https\", \"accept-encoding\"=\u003e\"gzip\", \":method\"=\u003e\"GET\", \":path\"=\u003e\"/index.html\"}, :stream_id=\u003e1}\n\"hello mruby-http2!!\\n\"\n{\"user-agent\"=\u003e\"mruby-http2/0.0.1\", \"accept\"=\u003e\"*/*\", \":authority\"=\u003e\"127.0.0.1:8080\", \":scheme\"=\u003e\"https\", \"accept-encoding\"=\u003e\"gzip\", \":method\"=\u003e\"GET\", \":path\"=\u003e\"/index.html\"}\n{\":status\"=\u003e\"200\"}\n200\n\"hello mruby-http2!!\\n\"\n20\n1\n\"---- set callback version ----\"\n\"recv_callback\"\n\"before_frame_send_callback\"\n\"send_callback\"\n\"on_frame_send_callback\"\n\"recv_callback\"\n\"on_frame_recv_callback\"\n\"recv_callback\"\n\"before_frame_send_callback\"\n\"send_callback\"\n\"on_frame_send_callback\"\n\"recv_callback\"\n\"header callback\"\n\"on_frame_recv_callback\"\n\"recv_callback\"\n\"recv_callback\"\n\"on_data_chunk_recv_callback\"\n\"on_frame_recv_callback\"\n\"recv_callback\"\n\"recv_callback\"\n\"on_frame_recv_callback\"\n\"on_stream_close_callback\"\n\"recv_callback\"\n\"before_frame_send_callback\"\n\"send_callback\"\n\"on_frame_send_callback\"\n{:body=\u003e\"hello mruby-http2!!\\n\", :body_length=\u003e20, :recieve_bytes=\u003e20.0, :response_headers=\u003e{\":status\"=\u003e\"200\"}, :frame_send_header_goway=\u003etrue, :request_headers=\u003e{\"user-agent\"=\u003e\"mruby-http2/0.0.1\", \"accept\"=\u003e\"*/*\", \":authority\"=\u003e\"127.0.0.1:8080\", \":scheme\"=\u003e\"https\", \"accept-encoding\"=\u003e\"gzip\", \":method\"=\u003e\"GET\", \":path\"=\u003e\"/index.html\"}, :stream_id=\u003e1}\n```\n\n# License\nunder the MIT License:\n\n* http://www.opensource.org/licenses/mit-license.php\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatsumotory%2Fmruby-http2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatsumotory%2Fmruby-http2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatsumotory%2Fmruby-http2/lists"}