Project

hknife

0.0
No commit activity in last 3 years
No release in over 3 years
hknife
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.12
~> 10.0
~> 3.0
~> 2.0
 Project Readme

hknife

Build Status

It's a client http library and inspired by sinatra. Focus on simpler and understand easily what request will be send from the code. Notice it's super alpha quality.

How to use

Sending get request

get('http://www.example.com').send

Request is not sent until calling send or response method.

Sending get request and post request with reponse of previous get request

res = get('http://www.example.com').response
post_form('http://www.example.com/', id: res.body['id]).response

Sending get request with specified header

get('http://93.184.216.34/').
  header(Host: 'www.example.com').
  send

Sending request asynchronously

get("http://www.example.com/request1").async do |res|
  puts res.body
end

get("http://www.example.com/request2").async do|res|
  puts res.body
end

Sending multiple requests and send post request after all request ends

reqs = get("http://www.example.com/request0").
  get("http://www.example.com/request1").
  get("http://www.example.com/request2")
  
post_form(reqs.response(0).body['uri'], 
  { "id" => reqs.response(1).body['id'], 
    "uri" => reqs.response(2).body['key1'] })

Get http response code

get('http://www.example.com').response.code