All Projects → alexandrubagu → simplehttp

alexandrubagu / simplehttp

Licence: MIT license
HTTP client for Elixir without dependencies

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to simplehttp

Punchclock
Make sure your asynchronous operations show up to work on time
Stars: ✭ 235 (+1368.75%)
Mutual labels:  http-client
EthernetWebServer SSL
Simple TLS/SSL Ethernet WebServer, HTTP Client and WebSocket Client library for for AVR, Portenta_H7, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52 and RASPBERRY_PI_PICO boards using Ethernet shields W5100, W5200, W5500, ENC28J60 or Teensy 4.1 NativeEthernet/QNEthernet. It now supports Ethernet TLS/SSL Client. The library supports …
Stars: ✭ 40 (+150%)
Mutual labels:  http-client
scope guard
Scope Guard & Defer C++
Stars: ✭ 107 (+568.75%)
Mutual labels:  no-dependencies
Elastic
An Elasticsearch REST API client for Rust
Stars: ✭ 248 (+1450%)
Mutual labels:  http-client
Axios
Promise based HTTP client for the browser and node.js
Stars: ✭ 89,857 (+561506.25%)
Mutual labels:  http-client
Rump
REST client for Java that allows for easy configuration and default values. Allows for quick request construction and a huge range of modifications by using response/request interceptors, adjusting default values related to HTTP requests and creating custom instances for when you need multiple API connection setups.
Stars: ✭ 55 (+243.75%)
Mutual labels:  http-client
Http Client
[Deprecated] Event-driven, streaming HTTP client for ReactPHP.
Stars: ✭ 228 (+1325%)
Mutual labels:  http-client
acc toolbar
Accessibility Toolbar Plugin
Stars: ✭ 42 (+162.5%)
Mutual labels:  no-dependencies
cpphttpstack
c++ api for http client & server
Stars: ✭ 30 (+87.5%)
Mutual labels:  http-client
Entia
Entia is a free, open-source, data-oriented, highly performant, parallelizable and extensible Entity-Component-System (ECS) framework written in C# especially for game development.
Stars: ✭ 28 (+75%)
Mutual labels:  no-dependencies
Csaguzzlebundle
A bundle integrating Guzzle >=4.0 in Symfony
Stars: ✭ 248 (+1450%)
Mutual labels:  http-client
Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+331475%)
Mutual labels:  http-client
http
ponylang HTTP client library 🐴 🕸️
Stars: ✭ 38 (+137.5%)
Mutual labels:  http-client
Urllib3
Python HTTP library with thread-safe connection pooling, file post support, user friendly, and more.
Stars: ✭ 2,857 (+17756.25%)
Mutual labels:  http-client
path-dsl-rs
A Rust utility DSL and macro to help construct and modify Paths.
Stars: ✭ 19 (+18.75%)
Mutual labels:  no-dependencies
Avhttp
avhttp is concurrent http downloader
Stars: ✭ 232 (+1350%)
Mutual labels:  http-client
typesense-dart
Dart client for Typesense
Stars: ✭ 50 (+212.5%)
Mutual labels:  http-client
hackernews
📰 HackerNews API
Stars: ✭ 40 (+150%)
Mutual labels:  http-client
pawn-requests
pawn-requests provides an API for interacting with HTTP(S) JSON APIs.
Stars: ✭ 56 (+250%)
Mutual labels:  http-client
ng-payment-card
💳 Responsive credit card component for Angular.
Stars: ✭ 27 (+68.75%)
Mutual labels:  no-dependencies

SimpleHttp Travis Hex.pm Hex.pm Hex.pm Coverage Status

Unlike other projects / libraries, SimpleHttp doesn't have other dependencies

SimpleHttp myfreeweb/httpotion edgurgel/httpoison
$ mix app.tree
simplehttp
└── elixir
	    
$ mix app.tree
httpotion
├── elixir
├── ssl
│   ├── crypto
│   └── public_key
│       ├── asn1
│       └── crypto
└── ibrowse
	    
$ mix app.tree
httpoison
├── elixir
└── hackney
    ├── crypto
    ├── asn1
    ├── public_key
    │   ├── asn1
    │   └── crypto
    ├── ssl
    │   ├── crypto
    │   └── public_key
    ├── idna
    ├── mimerl
    ├── certifi
    ├── ssl_verify_fun
    │   └── ssl
    └── metrics
	    

Hex Installation

  1. Add simplehttp to your list of dependencies in mix.exs:
def deps do
  [{:simplehttp, "~> 0.5.1"}]
end

Usage

Note:You can load SimpleHttp into the Elixir REPL by executing this command from the root of your project:

$ iex -S mix

Simple GET Request

{:ok, response} = SimpleHttp.get "http://jsonplaceholder.typicode.com/posts/1"

IO.inspect response 
{:ok,
%SimpleHttp.Response{
  body: "{\n  \"userId\": 1,\n  \"id\": 1,\n  \"title\": \"sunt aut facere repellat provident occaecati excepturi optio reprehenderit\",\n  \"body\": \"quia et suscipit\\nsuscipit recusandae consequuntur expedita et cum\\nreprehenderit molestiae ut ut quas totam\\nnostrum rerum est autem sunt rem eveniet architecto\"\n}",
  headers: [
    {'cache-control', 'public, max-age=14400'},
    {'connection', 'keep-alive'},
    {'date', 'Mon, 22 Oct 2018 07:02:48 GMT'},
    {'pragma', 'no-cache'},
    {'via', '1.1 vegur'},
    {'etag', 'W/"124-yiKdLzqO5gfBrJFrcdJ8Yq0LGnU"'},
    {'server', 'cloudflare'},
    {'vary', 'Origin, Accept-Encoding'},
    {'content-length', '292'},
    {'content-type', 'application/json; charset=utf-8'},
    {'expires', 'Mon, 22 Oct 2018 11:02:48 GMT'},
    {'set-cookie',
      '__cfduid=de34235eb1c3436a238889924c15be9671540191768; expires=Tue, 22-Oct-19 07:02:48 GMT; path=/; domain=.typicode.com; HttpOnly'},
    {'x-powered-by', 'Express'},
    {'access-control-allow-credentials', 'true'},
    {'x-content-type-options', 'nosniff'},
    {'cf-cache-status', 'HIT'},
    {'cf-ray', '46da19b6d5f87ea0-BUD'}
  ],
  status: 200
}}

Use headers_format: :binary option to return headers as strings:

SimpleHttp.get "http://jsonplaceholder.typicode.com/posts/1", headers_format: :binary |> IO.inspect

{:ok,
%SimpleHttp.Response{
  body: "{ ... }",
  headers: [
    {"cache-control", "public, max-age=14400"},
    {"connection", "keep-alive"},
    {"date", "Mon, 22 Oct 2018 07:02:48 GMT"},
    ...
  ],
  status: 200
}}

GET Request with query params

{:ok, response} = SimpleHttp.get "http://jsonplaceholder.typicode.com/posts/1", [
  query_params: [
    postId: 1
  ]
]

Download a file using a GET request

{:ok, %Response{body: :saved_to_file}} = SimpleHttp.get "https://jsonplaceholder.typicode.com/posts", [
  ssl: [verify: :verify_none], headers: %{"User-Agent" => "Mozilla"},
  stream: "/tmp/posts.xml",
  timeout: 5000
]

POST with JSON

{:ok, response} = SimpleHttp.post "http://jsonplaceholder.typicode.com/posts", [
  body: "{\"name\":\"foo.example.com\"}",
  headers: %{
    "Content-Type" => "application/x-www-form-urlencoded",
    "Authorization" => "Bearer hash",
    "X-Customer" => "123"
  },
  timeout: 1000,
  connect_timeout: 1000
]

POST with params

{:ok, response} = SimpleHttp.post "http://jsonplaceholder.typicode.com/posts", [
  params: [
    title: "title is present here",
    message: "hello world!"
  ],
  headers: %{
    "Content-Type" => "application/x-www-form-urlencoded",
    "Authorization" => "Bearer hash",
    "X-Customer" => "123"
  },
  timeout: 1000,
  connect_timeout: 1000
]

Run a request in a custom HTTP profile with custom options

{:ok, response} = SimpleHttp.get "https://jsonplaceholder.typicode.com/posts", [
  ssl: [verify: :verify_none], headers: %{"User-Agent" => "Mozilla"},
  timeout: 5000,
  profile: :test,
  verbose: :verbose
]
:ok = SimpleHttp.close(response)  # Stop the HTTPC :test profile
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].