nice_http 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +59 -0
  3. data/lib/nice_http.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 953a8e522904b4aa3a6540c60498d3d9b1680859108246abc28fde9f7d934c6f
4
- data.tar.gz: f9dad691419750bfd269b78c640fb091fc93861f8b3ddfead7a0300c737d9476
3
+ metadata.gz: 425c7cb8f8ed1196fde60bd2ccb0e3f96e8b020e78f36be07806f24ecd870340
4
+ data.tar.gz: 472dcb152fa486d8121f2ecf3482e4e2474b467f6616d606a01b50dab88ad9ec
5
5
  SHA512:
6
- metadata.gz: e33f131f2cab1ff058d2341a7d06608845d318813dd5ae96c53978c60d1ef20dde719331e580bcdbe98aafab62c62cd5b4e668a395286f10e54bf96e9e0adf47
7
- data.tar.gz: b550cfdd965307ac56d99209d4319b07db128fb99fcf81fbd6fff76b466d5f9364a5307068452ea8d3adca45f3f6da3b5889926d3fee92d0500e60b9537a797a
6
+ metadata.gz: 01d45597653f6af87582cbbff0d5bb34f429013e0dbf649eb75e9acf8d65f200a35f43154e26a03381c409e67389fd3c8ecf16fca1c8b6bb8dde55f2ef0a4ba9
7
+ data.tar.gz: e01f1cd9968013a7b27ab029e775feba356fa01933f4abf65b8c9b8942cc5e79f46afde0d7a04f61837bfccf773bb27e1fb5bf17b0d7cba74f0f58fde9364180
data/README.md CHANGED
@@ -219,6 +219,65 @@ resp = @http.get("/HTTP/Basic/")
219
219
 
220
220
  ```
221
221
 
222
+ Remember for other kind of authentication systems NiceHttp take care of the redirections and cookies that are requested to be set. In case you need to add a header with a token you can add it by using your NiceHttp object and the key headers, for example:
223
+
224
+ ```ruby
225
+ @http.headers.tokenuno = "xxx"
226
+ # headers => {tokenuno: "xxx"}
227
+
228
+ #another way:
229
+ @http.headers[:tokendos] = "yyy"
230
+ # headers => {tokenuno: "xxx", tokendos: "yyyy"}
231
+
232
+ ```
233
+
234
+ In case you want or need to control the redirections by yourself instead of allowing NiceHttp to do it, then set ```@http.auto_redirect = false```
235
+
236
+ An example using OpenID authentication:
237
+
238
+ ```ruby
239
+ server = "https://samples.auth0.com/"
240
+ path="/authorize?client_id=kbyuFDidLLm280LIwVFiazOqjO3ty8KH&response_type=code"
241
+
242
+ @http = NiceHttp.new(server)
243
+
244
+
245
+ resp = @http.get(path)
246
+
247
+ p "With autoredirection:"
248
+ p "Cookies: "
249
+ p @http.cookies
250
+ p "Code: #{resp.code} #{resp.message} "
251
+ p "*"*40
252
+
253
+ @http2 = NiceHttp.new(server)
254
+ @http2.auto_redirect = false
255
+
256
+ resp = @http2.get(path)
257
+
258
+ p "Without autoredirection:"
259
+ p "Cookies: "
260
+ p @http2.cookies
261
+ p "Code: #{resp.code} #{resp.message} "
262
+
263
+ ```
264
+
265
+ The output:
266
+
267
+ ```
268
+ "With autoredirection:"
269
+ "Cookies: "
270
+ {"/"=>{"auth0"=>"s%3A6vEEwmmIf-9YAG-NjvsOIyZAh-NS97jj.yFSXILdmCov6DRwXjEei3q3eHIrxZxHI4eg4%2BTpUaK4"}, "/usernamepassword/login"=>{"_csrf"=>"bboZ0koMScwXkISzWaAMTYdY"}}
271
+ "Code: 200 OK "
272
+ "****************************************"
273
+ "Without autoredirection:"
274
+ "Cookies: "
275
+ {"/"=>{"auth0"=>"s%3AcKndc44gllWyJv8FLztUIctuH4b__g0V.QEF3SOobK8%2FvX89iUKzGbfSP4Vt2bRtY2WH7ygBUkg4"}}
276
+ "Code: 302 Found "
277
+
278
+ ```
279
+
280
+
222
281
  ## Send multipart content
223
282
 
224
283
  Example posting a csv file:
@@ -205,7 +205,7 @@ class NiceHttp
205
205
  return @response
206
206
  end
207
207
  begin
208
- if path.include?("http:") or path.include?("https:") then #server included on path problably because of a redirection to a different server
208
+ if path.start_with?("http:") or path.start_with?("https:") then #server included on path problably because of a redirection to a different server
209
209
  require 'uri'
210
210
  uri = URI.parse(path)
211
211
  ssl=false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nice_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz