Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lpgauth/buoy
High-Performance Erlang HTTP 1.1 Client
https://github.com/lpgauth/buoy
erlang high-performance http http-client
Last synced: 7 days ago
JSON representation
High-Performance Erlang HTTP 1.1 Client
- Host: GitHub
- URL: https://github.com/lpgauth/buoy
- Owner: lpgauth
- License: mit
- Created: 2016-02-10T14:50:43.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-03-18T18:10:46.000Z (9 months ago)
- Last Synced: 2024-12-09T04:36:34.871Z (17 days ago)
- Topics: erlang, high-performance, http, http-client
- Language: Erlang
- Homepage:
- Size: 3.1 MB
- Stars: 77
- Watchers: 10
- Forks: 11
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# buoy
High-Performance Erlang HTTP 1.1 Client
![Build Status](https://github.com/lpgauth/buoy/workflows/Erlang%20CI/badge.svg)
## Disclaimer:
This HTTP client has been designed for HTTP 1.1 with keep-alive. For performance reasons, it only implements a subset of RFC2616.### Unsupported Features:
- Doesn't accept an arbitrary number of new lines in headers
- Doesn't accept random capitalization of content-length header
- Doesn't protect against malicious servers## API
Function Index## Examples
```erlang
1> buoy_app:start().
{ok,[granderl,shackle,buoy]}2> Url = buoy_utils:parse_url(<<"http://example.com">>).
{buoy_url,<<"example.com">>,<<"example.com">>,<<"/">>,80,
http}3> ok = buoy_pool:start(Url, [{pool_size, 1}]).
ok4> {ok, Resp} = buoy:get(Url, #{timeout => 500}).
{ok,{buoy_resp,done,
<<"\n\n\n Example Domain\n\n \n "...>>,
1270,
[<<"Cache-Control: max-age=604800">>,
<<"Content-Type: text/html">>,
<<"Date: Mon, 20 Mar 2017 14:48:25 GMT">>,
<<"Etag: \"359670651+gzip+ident\"">>,
<<"Expires: Mon, 27 Mar 2017 14:48:25 GMT">>,
<<"Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT">>,
<<"Server: ECS (cpm/F9D5)">>,<<"Vary: Accept-Encoding">>,
<<"X-Cache: HIT">>,<<"Content-Length: 1270">>],
<<"OK">>,200}}5> {ok, Headers} = buoy_protocol:headers(Resp).
{ok,[{<<"Cache-Control">>,<<"max-age=604800">>},
{<<"Content-Type">>,<<"text/html">>},
{<<"Date">>,<<"Mon, 20 Mar 2017 14:48:25 GMT">>},
{<<"Etag">>,<<"\"359670651+gzip+ident\"">>},
{<<"Expires">>,<<"Mon, 27 Mar 2017 14:48:25 GMT">>},
{<<"Last-Modified">>,<<"Fri, 09 Aug 2013 23:54:35 GMT">>},
{<<"Server">>,<<"ECS (cpm/F9D5)">>},
{<<"Vary">>,<<"Accept-Encoding">>},
{<<"X-Cache">>,<<"HIT">>},
{<<"Content-Length">>,<<"1270">>}]}
```### Pool Options
Name
Type
Default
Description
backlog_size
pos_integer()
1024
maximum number of concurrent requests per connection
pool_size
pos_integer()
16
number of connections
pool_strategy
random | round_robin
random
connection selection strategy
reconnect
boolean()
true
reconnect closed connections
reconnect_time_max
pos_integer() | infinity
120000
reconnect maximum time
reconnect_time_min
pos_integer()
500
reconnect minimum time
socket_options
[gen_tcp:connect_option() | ssl:tls_client_option()]
[binary,
{packet, line},
{packet, raw},
{send_timeout, 50},
{send_timeout_close, true}]
options passed to the socket when connecting
## Tests
```makefile
make dialyzer
make eunit
make xref
```## License
```license
The MIT License (MIT)Copyright (c) 2016-2023 Louis-Philippe Gauthier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```