yobi-http 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cd8930bcfe4c6abc945f290f82f4dbca27cbbbe7fb18592e76b0a78f7541325
4
- data.tar.gz: dddad8c7efc3aac7d4aaa5a95a67585ee62896f2721bd017fc4f15f8f348761a
3
+ metadata.gz: 56563ef37ac915d9ea34678799ac53ae2f8d91355dfd383e47929ea17e0814b0
4
+ data.tar.gz: cc47d7c2010c5177685cd75462e4c2c387befa2d31d117acaf5e99f23dc91e59
5
5
  SHA512:
6
- metadata.gz: 32b78e79f26f6e9a1c58165fc0cf50c1d299505a35135cb592c5a4c8e1a1355a16c483cb4486cada273623b1d7f56821a719326d33e536216cd73310abce8057
7
- data.tar.gz: eded11c1ac57fc5cd10c029e294465891ec352fbfa332c7de84cef47a1e3a9024742deb60a52ffbcd6f705699c3ea552ad668de40f7ffb1c230d12fcd2d82b65
6
+ metadata.gz: 90392c2e87b514c76c3f5b1eaa1049140f38ae2b0c87937379f2f767ba6fff1809b2143433479e99f18a5cb550165aa3003860b173247ddac08ab124a448423e
7
+ data.tar.gz: 63f13abd60c7e4580d504e2e5cf6b39fa919708309e21dc2371bc78750a7b7f52d9635c2a07561cb043fb5181b66975dde63d3a793e5e29563ab1d2fb8559aa8
data/README.md CHANGED
@@ -6,6 +6,7 @@ and flexible, allowing you to customize your requests as needed.
6
6
  Its a lightweight implementation of the HTTPie tool, which is a command-line HTTP client that allows you to make
7
7
  HTTP requests and view the responses in a human-friendly format.
8
8
 
9
+ ![](./screenshot.png)
9
10
 
10
11
  ## Installation
11
12
 
data/exe/yobi CHANGED
@@ -14,7 +14,9 @@ require "uri"
14
14
  require "yobi"
15
15
 
16
16
  # parsing arguments
17
- @options = { print: "HB", auth: nil, auth_type: "basic", verbose: false, raw: false, offline: false }
17
+ @options = {
18
+ print: "HB", auth: nil, auth_type: "basic", verbose: false, raw: false, offline: false, follow: false, debug: false
19
+ }
18
20
 
19
21
  parser = OptionParser.new do |opts|
20
22
  opts.banner = %(
@@ -59,12 +61,22 @@ parser = OptionParser.new do |opts|
59
61
  @options[:offline] = true
60
62
  end
61
63
 
64
+ opts.on("--follow", "Automatically follow HTTP redirects") do
65
+ @options[:follow] = true
66
+ end
67
+
62
68
  opts.on("-o", "--output FILE", "Write output to a file instead of STDOUT") do |file|
63
69
  @options[:output] = file
64
70
  end
65
71
 
66
72
  opts.on("-v", "--verbose", "Print detailed request and response information") do
67
73
  @options[:verbose] = true
74
+
75
+ end
76
+
77
+ opts.on("--debug", "Print debug information") do
78
+ @options[:debug] = true
79
+ @options[:verbose] = true
68
80
  end
69
81
 
70
82
  opts.on("--version", "Print app version") do
@@ -126,12 +138,30 @@ def raw_mode(_request, response, options)
126
138
  exit 0
127
139
  end
128
140
 
141
+ def follow_redirects(response, url, method, data, headers, options)
142
+ return response unless response.is_a?(Net::HTTPRedirection)
143
+
144
+ location = response["location"]
145
+ warn "Redirected to #{location}" if options[:debug]
146
+ new_url = URI.join(url, location).to_s
147
+
148
+ Yobi.request(method, new_url, data: data, headers: headers, options: options) do |new_http, new_request|
149
+ response = new_http.request(new_request)
150
+ return follow_redirects(response, new_url, method, data, headers, options)
151
+ end
152
+ end
153
+
129
154
  Yobi.request(method, url, data: data, headers: headers, options: @options) do |http, request|
130
155
  options = @options
131
156
 
132
157
  offline_mode(request, options) if options[:offline]
133
158
 
134
- response = http.request(request)
159
+ response =
160
+ if options[:follow]
161
+ follow_redirects(http.request(request), url, method, data, headers, options)
162
+ else
163
+ http.request(request)
164
+ end
135
165
 
136
166
  raw_mode(request, response, options) if options[:raw]
137
167
 
data/lib/yobi/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Yobi
4
4
  # Yobi gem version
5
- VERSION = "0.8.0"
5
+ VERSION = "0.10.0"
6
6
  end
data/screenshot.png ADDED
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yobi-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vinciguerra
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-02-20 00:00:00.000000000 Z
10
+ date: 2026-02-22 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: base64
@@ -62,6 +62,7 @@ files:
62
62
  - lib/yobi/extensions/net_http/parsing.rb
63
63
  - lib/yobi/http.rb
64
64
  - lib/yobi/version.rb
65
+ - screenshot.png
65
66
  - spec/extensions/net_http/parsing_spec.rb
66
67
  - spec/spec_helper.rb
67
68
  - spec/support/webmock.rb