{"id":17464492,"url":"https://github.com/overbryd/http_client","last_synced_at":"2025-04-19T19:02:47.006Z","repository":{"id":11557567,"uuid":"14043708","full_name":"Overbryd/http_client","owner":"Overbryd","description":"This library wraps the Apache HTTPClient (4.3) in a simple fashion.","archived":false,"fork":false,"pushed_at":"2014-11-24T13:09:48.000Z","size":1116,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T10:16:34.696Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Overbryd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-01T13:29:16.000Z","updated_at":"2017-09-01T12:59:06.000Z","dependencies_parsed_at":"2022-09-15T08:20:24.093Z","dependency_job_id":null,"html_url":"https://github.com/Overbryd/http_client","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/Overbryd%2Fhttp_client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Overbryd%2Fhttp_client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Overbryd%2Fhttp_client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Overbryd%2Fhttp_client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Overbryd","download_url":"https://codeload.github.com/Overbryd/http_client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249771391,"owners_count":21323083,"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-18T10:45:59.983Z","updated_at":"2025-04-19T19:02:46.971Z","avatar_url":"https://github.com/Overbryd.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A simple yet powerful HTTP client for JRuby\n\nThis library wraps the Apache HttpClient (4.3) in a simple fashion.\nIt currently implements all common HTTP verbs, connection pooling, retries and transparent gzip response handling. All common exceptions from Javaland are wrapped as Ruby exceptions. The library is intended to be used in a multithreaded environment.\n\nIt is currently in use in some of my production environments, including one that frequently talks to Facebook. I could not find a single issue since 2013.\n\n## Examples\n\n#### A simple GET request\n\n```ruby\nrequire \"http_client\"\n\nclient = HttpClient.new\nresponse = client.get(\"http://www.google.com/robots.txt\")\n\nresponse.status\n# =\u003e 200\n\nresponse.body\n# =\u003e\n# User-agent: *\n# ...\n```\n\n#### POST a form\n\n```ruby\nresponse = client.post(\"http://geocities.com/darrensden/guestbook\",\n  :form =\u003e {\n    :name =\u003e \"Joe Stub\",\n    :email =\u003e \"joey@ymail.com\",\n    :comment =\u003e \"Hey, I really like your site! Awesome stuff\"\n  }\n)\n```\n\n#### POST JSON data\n\n```ruby\nresponse = client.post(\"http://webtwoopointo.com/v1/api/guestbooks/123/comments\",\n  :json =\u003e {\n    :name =\u003e \"Jason\",\n    :email =\u003e \"jason@gmail.com\",\n    :comment =\u003e \"Your site is great!\"\n  }\n)\n```\n\n#### Provide request headers\n\n```ruby\nresponse = client.get(\"http://secretservice.com/users/123\",\n  :headers =\u003e { \"X-Auth\": \"deadbeef23\" }\n)\n```\n\n#### Using a connection pool\n\nRather than opening a new connection each and every time, you can pool connections to your target host. Using `:use_connection_pool =\u003e true` gives you fine grained control over the total number of connections and the number of connections your client will maintain to each route.\n\n```ruby\n$client = HttpClient.new(\n  :use_connection_pool =\u003e true,\n  :max_connections =\u003e 3,\n  :max_connections_per_route =\u003e 1\n)\n\n%[www.google.de www.yahoo.com www.altavista.com].each do |host|\n  Thread.new do\n    response = $client.get(\"http://#{host}/robots.txt\")\n    puts response.body\n  end\nend\n```\n\n##### Connection pool cleanup\n\n**tl;dr This library does this by default.** \nIn case you do not want _one extra thread_ cleaning after all `HttpClient` instances that use connection pooling, you can set the option `:use_connection_cleaner =\u003e false` and call `HttpClient#cleanup_connections` manually.\nThe background on this is, that you should actively expire your idle connections from the client side. Doing so will prevent you from ending up with too many `CLOSE-WAIT` connections. There are servers that never close the connection from their side, leaving the task up to the client.\n\n## Contribute\n\nThis library covers just what I need. I wanted to have a thread safe HTTP client that supports a fixed connection pool with fine grained connection and timeout configurations.\n\nBefore you start hacking away, [have a look at the issues](https://github.com/Overbryd/http_client/issues). There might be stuff that is already in the making. If so, there will be a published branch you can contribute to.\n\nJust create a fork and send me a pull request. I would be honored to look at your input.\n\n[![Build Status](https://travis-ci.org/Overbryd/http_client.png)](https://travis-ci.org/Overbryd/http_client)\n\n## Legal\n\nCopyright by Lukas Rieder, 2013, Licensed under the MIT License, see LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foverbryd%2Fhttp_client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foverbryd%2Fhttp_client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foverbryd%2Fhttp_client/lists"}