Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A HTTP-framework for Ruby supporting keep-alive, compression, JSON-posting, detailed inspection of responses and much more.
require "rubygems"
require "http2"
Http2.new(host: "www.google.dk") do |http|
# Do requests here.
end
Or without using a block for ensuring closing of connection:
http = Http2.new(...)
# Do requests here.
http.destroy # Closes the connection and frees up any variables used
Or through a proxy:
Http2.new(host: "www.google.com", proxy: {host: "myproxy.com", port: 80, user: "myname", passwd: "mypassword"})
You can also use SSL:
Http2.new(host: "myhost.com", ssl: true, ssl_skip_verify: true)
You can make it follow redirects like this:
Http2.new(host: "myhost.com", follow_redirects: true)
res = http.get("path/to/something")
Or as a hash:
res = http.get(url: "path/to/something")
res = http.post(url: "path/to/something", post: {
"some_post_val" => "some_value"
})
res = http.post(
url: "path",
headers: {"Auth": "123"},
post: {data: "test"}
)
res = http.post(url: "path/to/something", json: {some_argument: true})
res = http.post(url: "something", json: {some_argument: true})
res.json? #=> true (if content-type is application/json)
res.json #=> {"value" => "something"}
res = http.delete(url: "path/to/something")
res = http.post_multipart(url: "path/to/something", post: {
"test_file1" => {
fpath: fpath,
filename: "specfile"
}
})
puts "Cookies until now: #{http.cookies}"
ub = ::Http2::UrlBuilder.new
ub.host = "www.google.com"
ub.port = 80
ub.path = "script.php"
ub.params["some_param"] = 2
ub.build #=> "http://www.google.com/..."
ub.build_params #=> "some_param=2&some_other_param=..."
ub.build_path_and_params #=> "script.php?some_param=2"
ub.params? #=> true
ub.host #=> "www.google.com"
ub.port #=> 80
ub.path #=> "script.php"
resp = http.get("path/to/something")
resp.content_type #=> "text/html"
resp.content_length #=> 136
resp.header("content-length") #=> "136"
resp.headers #=> {"content-type" => ["text/html"], "content-length" => ["136"]}
resp.code #=> "200"
resp.charset #=> "utf-8"
resp.http_version #=> "1.1"
resp.body #=> "<html><body>..."
resp.requested_url #=> "http://example.com/maybe/redirected/path/to/something"
http.host #=> example.com
http.port #=> 80
Handy when doing retries.
http.reconnect
http = Http2.new(
host: "www.somehost.com",
basic_auth: {
user: "username",
passwd: "password"
}
)
response = http.get("some_page")
request = response.request
request.headers_string #=> "GET /some_page\n..."
Copyright (c) 2012 Kasper Johansen. See LICENSE.txt for further details.
FAQs
Unknown package
We found that http2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.