htty 1.0.0 → 1.1.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.
Files changed (92) hide show
  1. data/History.markdown +21 -0
  2. data/MIT-LICENSE.markdown +10 -0
  3. data/README.markdown +238 -0
  4. data/VERSION +1 -1
  5. data/bin/htty +1 -1
  6. data/{app → lib}/htty.rb +0 -2
  7. data/{app → lib}/htty/cli.rb +11 -4
  8. data/{app → lib}/htty/cli/command.rb +25 -3
  9. data/{app → lib}/htty/cli/commands.rb +0 -2
  10. data/{app → lib}/htty/cli/commands/address.rb +15 -9
  11. data/{app → lib}/htty/cli/commands/body_clear.rb +0 -2
  12. data/{app → lib}/htty/cli/commands/body_request.rb +1 -3
  13. data/{app → lib}/htty/cli/commands/body_response.rb +1 -3
  14. data/{app → lib}/htty/cli/commands/body_set.rb +9 -4
  15. data/{app → lib}/htty/cli/commands/body_unset.rb +1 -3
  16. data/{app → lib}/htty/cli/commands/cd.rb +0 -2
  17. data/{app → lib}/htty/cli/commands/cookie_add.rb +0 -2
  18. data/{app → lib}/htty/cli/commands/cookie_remove.rb +0 -2
  19. data/{app → lib}/htty/cli/commands/cookies.rb +9 -5
  20. data/{app → lib}/htty/cli/commands/cookies_add.rb +1 -3
  21. data/{app → lib}/htty/cli/commands/cookies_clear.rb +0 -2
  22. data/{app → lib}/htty/cli/commands/cookies_remove.rb +1 -3
  23. data/{app → lib}/htty/cli/commands/cookies_remove_all.rb +1 -3
  24. data/{app → lib}/htty/cli/commands/cookies_use.rb +11 -4
  25. data/{app → lib}/htty/cli/commands/delete.rb +0 -2
  26. data/{app → lib}/htty/cli/commands/exit.rb +0 -2
  27. data/{app → lib}/htty/cli/commands/follow.rb +6 -9
  28. data/{app → lib}/htty/cli/commands/form.rb +0 -2
  29. data/{app → lib}/htty/cli/commands/form_add.rb +0 -2
  30. data/{app → lib}/htty/cli/commands/form_clear.rb +0 -2
  31. data/{app → lib}/htty/cli/commands/form_remove.rb +0 -2
  32. data/{app → lib}/htty/cli/commands/form_remove_all.rb +0 -2
  33. data/{app → lib}/htty/cli/commands/fragment_clear.rb +0 -2
  34. data/{app → lib}/htty/cli/commands/fragment_set.rb +6 -4
  35. data/{app → lib}/htty/cli/commands/fragment_unset.rb +4 -4
  36. data/{app → lib}/htty/cli/commands/get.rb +0 -2
  37. data/{app → lib}/htty/cli/commands/header_set.rb +0 -2
  38. data/{app → lib}/htty/cli/commands/header_unset.rb +0 -2
  39. data/{app → lib}/htty/cli/commands/headers_clear.rb +0 -2
  40. data/{app → lib}/htty/cli/commands/headers_request.rb +13 -8
  41. data/{app → lib}/htty/cli/commands/headers_response.rb +6 -4
  42. data/{app → lib}/htty/cli/commands/headers_set.rb +1 -3
  43. data/{app → lib}/htty/cli/commands/headers_unset.rb +1 -4
  44. data/{app → lib}/htty/cli/commands/headers_unset_all.rb +1 -3
  45. data/{app → lib}/htty/cli/commands/help.rb +8 -4
  46. data/{app → lib}/htty/cli/commands/history.rb +5 -7
  47. data/{app → lib}/htty/cli/commands/history_verbose.rb +6 -5
  48. data/{app → lib}/htty/cli/commands/host_set.rb +2 -7
  49. data/{app → lib}/htty/cli/commands/http_delete.rb +0 -2
  50. data/{app → lib}/htty/cli/commands/http_get.rb +0 -2
  51. data/{app → lib}/htty/cli/commands/http_head.rb +0 -2
  52. data/{app → lib}/htty/cli/commands/http_options.rb +0 -2
  53. data/{app → lib}/htty/cli/commands/http_post.rb +0 -2
  54. data/{app → lib}/htty/cli/commands/http_put.rb +0 -2
  55. data/{app → lib}/htty/cli/commands/http_trace.rb +0 -2
  56. data/{app → lib}/htty/cli/commands/path_set.rb +6 -4
  57. data/{app → lib}/htty/cli/commands/port_set.rb +4 -4
  58. data/{app → lib}/htty/cli/commands/post.rb +0 -2
  59. data/{app → lib}/htty/cli/commands/put.rb +0 -2
  60. data/{app → lib}/htty/cli/commands/query_clear.rb +0 -2
  61. data/{app → lib}/htty/cli/commands/query_set.rb +10 -7
  62. data/{app → lib}/htty/cli/commands/query_unset.rb +12 -6
  63. data/{app → lib}/htty/cli/commands/query_unset_all.rb +4 -4
  64. data/{app → lib}/htty/cli/commands/quit.rb +0 -2
  65. data/{app → lib}/htty/cli/commands/reuse.rb +4 -3
  66. data/{app → lib}/htty/cli/commands/scheme_set.rb +4 -4
  67. data/{app → lib}/htty/cli/commands/status.rb +8 -5
  68. data/{app → lib}/htty/cli/commands/undo.rb +0 -2
  69. data/{app → lib}/htty/cli/commands/userinfo_clear.rb +0 -2
  70. data/{app → lib}/htty/cli/commands/userinfo_set.rb +30 -8
  71. data/{app → lib}/htty/cli/commands/userinfo_unset.rb +4 -4
  72. data/{app → lib}/htty/cli/display.rb +40 -19
  73. data/{app → lib}/htty/cli/http_method_command.rb +4 -8
  74. data/{app → lib}/htty/cli/url_escaping.rb +0 -2
  75. data/{app → lib}/htty/cookies_util.rb +0 -2
  76. data/{app → lib}/htty/no_location_header_error.rb +3 -2
  77. data/{app → lib}/htty/no_response_error.rb +0 -2
  78. data/{app → lib}/htty/no_set_cookie_header_error.rb +3 -2
  79. data/{app → lib}/htty/ordered_hash.rb +2 -3
  80. data/{app → lib}/htty/payload.rb +2 -3
  81. data/{app → lib}/htty/request.rb +25 -15
  82. data/{app → lib}/htty/requests_util.rb +2 -3
  83. data/{app → lib}/htty/response.rb +2 -3
  84. data/{app → lib}/htty/session.rb +0 -2
  85. data/spec/unit/htty/cli_spec.rb +9 -14
  86. data/spec/unit/htty/ordered_hash_spec.rb +13 -17
  87. data/spec/unit/htty/request_spec.rb +281 -127
  88. data/spec/unit/htty/session_spec.rb +4 -7
  89. metadata +152 -99
  90. data/MIT-LICENSE.rdoc +0 -9
  91. data/README.rdoc +0 -199
  92. data/app/htty/cli/cookie_clearing_command.rb +0 -26
@@ -1,6 +1,5 @@
1
- # Defines HTTY::RequestsUtil.
2
-
3
1
  require 'net/http'
2
+ require 'net/https'
4
3
  require 'uri'
5
4
  require File.expand_path("#{File.dirname __FILE__}/response")
6
5
 
@@ -74,7 +73,7 @@ private
74
73
 
75
74
  def self.request(request)
76
75
  http = Net::HTTP.new(request.uri.host, request.uri.port)
77
- http.use_ssl = true if (request.uri === URI::HTTPS)
76
+ http.use_ssl = true if request.uri.kind_of?(URI::HTTPS)
78
77
  http.start do |host|
79
78
  http_response = yield(host)
80
79
  headers = []
@@ -1,5 +1,3 @@
1
- # Defines HTTY::Response.
2
-
3
1
  require File.expand_path("#{File.dirname __FILE__}/cookies_util")
4
2
  require File.expand_path("#{File.dirname __FILE__}/payload")
5
3
 
@@ -8,7 +6,8 @@ module HTTY; end
8
6
  # Encapsulates an HTTP(S) response.
9
7
  class HTTY::Response < HTTY::Payload
10
8
 
11
- COOKIES_HEADER_NAME = 'Set-Cookie'
9
+ COOKIES_HEADER_NAME = 'Set-Cookie'
10
+ LOCATION_HEADER_NAME = 'Location'
12
11
 
13
12
  # Returns the HTTP status associated with the response.
14
13
  attr_reader :status
@@ -1,5 +1,3 @@
1
- # Defines HTTY::Session.
2
-
3
1
  require File.expand_path("#{File.dirname __FILE__}/request")
4
2
 
5
3
  module HTTY; end
@@ -1,27 +1,22 @@
1
1
  require 'spec'
2
- require File.expand_path("#{File.dirname __FILE__}/../../../app/htty/cli")
3
- require File.expand_path("#{File.dirname __FILE__}/../../../app/htty/request")
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/cli")
3
+ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/request")
4
4
 
5
5
  describe HTTY::CLI do
6
6
  describe 'with empty arguments' do
7
- before :each do
8
- @cli = HTTY::CLI.new([])
9
- end
10
-
11
7
  it 'should have a session with the URI http://0.0.0.0:80/' do
12
- @cli.session.requests.should == [HTTY::Request.new('http://0.0.0.0:80/')]
8
+ cli = HTTY::CLI.new([])
9
+ cli.session.requests.should == [HTTY::Request.new('http://0.0.0.0:80/')]
13
10
  end
14
11
  end
15
12
 
16
13
  describe 'with an address argument' do
17
- before :each do
18
- @cli = HTTY::CLI.new(%w(http://njonsson@github.com/njonsson/htty))
19
- end
20
-
21
14
  it 'should have a session with a URI corresponding to the address' do
22
- @cli.session.requests.should == [HTTY::Request.new('http://' +
23
- 'njonsson@github.com' +
24
- '/njonsson/htty')]
15
+ cli = HTTY::CLI.new(%w(https://njonsson@github.com/njonsson/htty))
16
+ cli.session.requests.should == [HTTY::Request.new('https://' +
17
+ 'njonsson@github.com' +
18
+ ':443' +
19
+ '/njonsson/htty')]
25
20
  end
26
21
  end
27
22
  end
@@ -1,53 +1,49 @@
1
1
  require 'spec'
2
- require File.expand_path("#{File.dirname __FILE__}/../../../app/htty/ordered_hash")
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/ordered_hash")
3
3
 
4
4
  describe HTTY::OrderedHash do
5
5
  describe 'that is empty' do
6
- before :each do
7
- @hash = HTTY::OrderedHash.new
8
- end
6
+ let(:hash) { HTTY::OrderedHash.new }
9
7
 
10
8
  it 'should be empty' do
11
- @hash.should be_empty
9
+ hash.should be_empty
12
10
  end
13
11
 
14
12
  describe '-- when values are added out of order' do
15
13
  before :each do
16
- @hash['foo'] = 'bar'
17
- @hash['baz'] = 'qux'
14
+ hash['foo'] = 'bar'
15
+ hash['baz'] = 'qux'
18
16
  end
19
17
 
20
18
  it '-- should have the expected values' do
21
- @hash.should == {'foo' => 'bar', 'baz' => 'qux'}
19
+ hash.should == {'foo' => 'bar', 'baz' => 'qux'}
22
20
  end
23
21
 
24
22
  it '-- should return the expected array when sent #to_a' do
25
- @hash.to_a.should == [%w(foo bar), %w(baz qux)]
23
+ hash.to_a.should == [%w(foo bar), %w(baz qux)]
26
24
  end
27
25
  end
28
26
  end
29
27
 
30
28
  describe 'that has values out of order' do
31
- before :each do
32
- @hash = HTTY::OrderedHash.new('foo' => 'bar', 'baz' => 'qux')
33
- end
29
+ let(:hash) { HTTY::OrderedHash.new('foo' => 'bar', 'baz' => 'qux') }
34
30
 
35
31
  it 'should have the expected values' do
36
- @hash.should == {'foo' => 'bar', 'baz' => 'qux'}
32
+ hash.should == {'foo' => 'bar', 'baz' => 'qux'}
37
33
  end
38
34
 
39
35
  it 'should index the values as expected' do
40
- @hash['foo'].should == 'bar'
41
- @hash['baz'].should == 'qux'
36
+ hash['foo'].should == 'bar'
37
+ hash['baz'].should == 'qux'
42
38
  end
43
39
 
44
40
  describe '-- when sent #clear' do
45
41
  before :each do
46
- @hash.clear
42
+ hash.clear
47
43
  end
48
44
 
49
45
  it '-- should be empty' do
50
- @hash.should be_empty
46
+ hash.should be_empty
51
47
  end
52
48
  end
53
49
  end
@@ -1,10 +1,25 @@
1
1
  require 'spec'
2
- require File.expand_path("#{File.dirname __FILE__}/../../../app/htty/request")
3
- require File.expand_path("#{File.dirname __FILE__}/../../../app/htty/response")
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/request")
3
+ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/response")
4
4
 
5
5
  shared_examples_for 'an empty request' do
6
6
  it 'should have only the default headers' do
7
- @request.headers.should == [%w(User-Agent htty/1.0.0)]
7
+ @request.headers.should == [%w(User-Agent htty/1.1.0)]
8
+ end
9
+
10
+ it 'should have no body' do
11
+ @request.body.should be_nil
12
+ end
13
+
14
+ it 'should have no response' do
15
+ @request.response.should be_nil
16
+ end
17
+ end
18
+
19
+ shared_examples_for 'an empty, authenticated request' do
20
+ it 'should the expected Authorization header plus the default headers' do
21
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
22
+ ['Authorization', 'Basic bmpvbnNzb24=']]
8
23
  end
9
24
 
10
25
  it 'should have no body' do
@@ -21,50 +36,50 @@ describe HTTY::Request do
21
36
  describe 'an invalid IPv4 address having' do
22
37
  describe 'consecutive dots' do
23
38
  it 'should raise URI::InvalidURIError' do
24
- lambda {
39
+ expect {
25
40
  HTTY::Request.new '1.2.3..4'
26
- }.should raise_error(URI::InvalidURIError)
41
+ }.to raise_error(URI::InvalidURIError)
27
42
  end
28
43
  end
29
44
 
30
45
  describe 'no dots' do
31
46
  it 'should raise URI::InvalidURIError' do
32
- lambda {
47
+ expect {
33
48
  HTTY::Request.new '1234'
34
- }.should raise_error(URI::InvalidURIError)
49
+ }.to raise_error(URI::InvalidURIError)
35
50
  end
36
51
  end
37
52
 
38
53
  describe 'too few dotted decimals' do
39
54
  it 'should raise URI::InvalidURIError' do
40
- lambda {
55
+ expect {
41
56
  HTTY::Request.new '1.2.3'
42
- }.should raise_error(URI::InvalidURIError)
57
+ }.to raise_error(URI::InvalidURIError)
43
58
  end
44
59
  end
45
60
 
46
61
  describe 'too many dotted decimals' do
47
62
  it 'should raise URI::InvalidURIError' do
48
- lambda {
63
+ expect {
49
64
  HTTY::Request.new '1.2.3.4.5'
50
- }.should raise_error(URI::InvalidURIError)
65
+ }.to raise_error(URI::InvalidURIError)
51
66
  end
52
67
  end
53
68
 
54
69
  describe 'a dotted decimal out of range' do
55
70
  it 'should raise URI::InvalidURIError' do
56
- lambda {
71
+ expect {
57
72
  HTTY::Request.new '1.2.3.1000'
58
- }.should raise_error(URI::InvalidURIError)
73
+ }.to raise_error(URI::InvalidURIError)
59
74
  end
60
75
  end
61
76
  end
62
77
 
63
78
  describe 'an invalid hostname having a leading hyphen' do
64
79
  it 'should raise URI::InvalidURIError' do
65
- lambda {
80
+ expect {
66
81
  HTTY::Request.new '-google.com'
67
- }.should raise_error(URI::InvalidURIError)
82
+ }.to raise_error(URI::InvalidURIError)
68
83
  end
69
84
  end
70
85
  end
@@ -156,6 +171,18 @@ describe HTTY::Request do
156
171
  it_should_behave_like 'an empty request'
157
172
  end
158
173
 
174
+ describe 'the HTTPS scheme, userinfo, and a hostname' do
175
+ before :each do
176
+ @request = HTTY::Request.new('https://njonsson@github.com')
177
+ end
178
+
179
+ it 'should have an HTTPS URI for host with that userinfo' do
180
+ @request.uri.should == URI.parse('https://njonsson@github.com:443/')
181
+ end
182
+
183
+ it_should_behave_like 'an empty, authenticated request'
184
+ end
185
+
159
186
  describe 'a hostname and the root path' do
160
187
  before :each do
161
188
  @request = HTTY::Request.new('github.com/')
@@ -168,6 +195,18 @@ describe HTTY::Request do
168
195
  it_should_behave_like 'an empty request'
169
196
  end
170
197
 
198
+ describe 'a hostname, port 443, and the root path' do
199
+ before :each do
200
+ @request = HTTY::Request.new('github.com:443/')
201
+ end
202
+
203
+ it 'should have an HTTPS URI for the root of that host' do
204
+ @request.uri.should == URI.parse('https://github.com:443/')
205
+ end
206
+
207
+ it_should_behave_like 'an empty request'
208
+ end
209
+
171
210
  describe 'the HTTP scheme, a hostname, port 443, and the root path' do
172
211
  before :each do
173
212
  @request = HTTY::Request.new('http://github.com:443/')
@@ -249,10 +288,10 @@ describe HTTY::Request do
249
288
  it_should_behave_like 'an empty request'
250
289
  end
251
290
 
252
- describe 'the HTTP scheme, userinfo, a hostname, a port, a path, a query ' +
253
- 'string, and a fragment' do
291
+ describe 'the HTTPS scheme, userinfo, a hostname, a port, a path, a ' +
292
+ 'query string, and a fragment' do
254
293
  before :each do
255
- @request = HTTY::Request.new('http://njonsson@github.com:123' +
294
+ @request = HTTY::Request.new('https://njonsson@github.com:123' +
256
295
  '/search/deep?q=http&lang=en#content')
257
296
  end
258
297
 
@@ -262,15 +301,15 @@ describe HTTY::Request do
262
301
  end
263
302
 
264
303
  describe '-- and is untouched --' do
265
- it 'should have an HTTP URI for that query string and that ' +
304
+ it 'should have an HTTPS URI for that query string and that ' +
266
305
  'fragment of that path on that host on that port with that ' +
267
306
  'userinfo' do
268
- @request.uri.should == URI.parse('http://njonsson@github.com:123' +
269
- '/search/deep?q=http&lang=en' +
307
+ @request.uri.should == URI.parse('https://njonsson@github.com:123' +
308
+ '/search/deep?q=http&lang=en' +
270
309
  '#content')
271
310
  end
272
311
 
273
- it_should_behave_like 'an empty request'
312
+ it_should_behave_like 'an empty, authenticated request'
274
313
  end
275
314
 
276
315
  describe '-- when sent #address with an address consisting of' do
@@ -290,7 +329,19 @@ describe HTTY::Request do
290
329
  '#flames')
291
330
  end
292
331
 
293
- it_should_behave_like 'an empty request'
332
+ it 'should the expected Authorization header plus the default ' +
333
+ 'headers' do
334
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
335
+ ['Authorization', 'Basic c3RldmU=']]
336
+ end
337
+
338
+ it 'should have no body' do
339
+ @request.body.should be_nil
340
+ end
341
+
342
+ it 'should have no response' do
343
+ @request.response.should be_nil
344
+ end
294
345
  end
295
346
 
296
347
  describe 'a different hostname --' do
@@ -309,17 +360,32 @@ describe HTTY::Request do
309
360
  describe '-- when sent #scheme_set with' do
310
361
  describe 'the same scheme --' do
311
362
  before :each do
312
- @request.scheme_set 'http'
363
+ @request.scheme_set 'https'
313
364
  end
314
365
 
315
366
  it 'should have an unchanged URI' do
367
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
368
+ ':123' +
369
+ '/search/deep?q=http&lang=en' +
370
+ '#content')
371
+ end
372
+
373
+ it_should_behave_like 'an empty, authenticated request'
374
+ end
375
+
376
+ describe 'a different scheme --' do
377
+ before :each do
378
+ @request.scheme_set 'http'
379
+ end
380
+
381
+ it 'should have the same URI, with the changed scheme' do
316
382
  @request.uri.should == URI.parse('http://njonsson@github.com' +
317
383
  ':123' +
318
384
  '/search/deep?q=http&lang=en' +
319
385
  '#content')
320
386
  end
321
387
 
322
- it_should_behave_like 'an empty request'
388
+ it_should_behave_like 'an empty, authenticated request'
323
389
  end
324
390
  end
325
391
 
@@ -330,27 +396,67 @@ describe HTTY::Request do
330
396
  end
331
397
 
332
398
  it 'should have an unchanged URI' do
333
- @request.uri.should == URI.parse('http://njonsson@github.com' +
399
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
334
400
  ':123' +
335
401
  '/search/deep?q=http&lang=en' +
336
402
  '#content')
337
403
  end
338
404
 
339
- it_should_behave_like 'an empty request'
405
+ it_should_behave_like 'an empty, authenticated request'
340
406
  end
341
407
 
342
- describe 'different userinfo --' do
343
- before :each do
344
- @request.userinfo_set 'nils'
345
- end
408
+ describe 'different userinfo' do
409
+ describe "that does not contain '@' --" do
410
+ before :each do
411
+ @request.userinfo_set 'nils'
412
+ end
346
413
 
347
- it 'should have the same URI, with the changed userinfo' do
348
- @request.uri.should == URI.parse('http://nils@github.com:123' +
349
- '/search/deep?q=http&lang=en' +
350
- '#content')
414
+ it 'should have the same URI, with the changed userinfo' do
415
+ @request.uri.should == URI.parse('https://nils@github.com:123' +
416
+ '/search/deep?q=http&lang=en' +
417
+ '#content')
418
+ end
419
+
420
+ it 'should the expected Authorization header plus the default ' +
421
+ 'headers' do
422
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
423
+ ['Authorization', 'Basic bmlscw==']]
424
+ end
425
+
426
+ it 'should have no body' do
427
+ @request.body.should be_nil
428
+ end
429
+
430
+ it 'should have no response' do
431
+ @request.response.should be_nil
432
+ end
351
433
  end
352
434
 
353
- it_should_behave_like 'an empty request'
435
+ describe "that contains an escaped '@' --" do
436
+ before :each do
437
+ @request.userinfo_set 'n%45'
438
+ end
439
+
440
+ it 'should have the same URI, with the changed userinfo' do
441
+ @request.uri.should == URI.parse('https://n%45@github.com:123' +
442
+ '/search/deep?q=http&lang=en' +
443
+ '#content')
444
+ end
445
+
446
+ it 'should the expected Authorization header plus the default ' +
447
+ 'headers' do
448
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
449
+ ['Authorization', 'Basic bkU=']]
450
+ end
451
+
452
+ it 'should have no body' do
453
+ @request.body.should be_nil
454
+ end
455
+
456
+ it 'should have no response' do
457
+ @request.response.should be_nil
458
+ end
459
+ end
354
460
  end
355
461
  end
356
462
 
@@ -360,7 +466,7 @@ describe HTTY::Request do
360
466
  end
361
467
 
362
468
  it 'should have the same URI, without userinfo' do
363
- @request.uri.should == URI.parse('http://github.com:123' +
469
+ @request.uri.should == URI.parse('https://github.com:123' +
364
470
  '/search/deep?q=http&lang=en' +
365
471
  '#content')
366
472
  end
@@ -375,13 +481,13 @@ describe HTTY::Request do
375
481
  end
376
482
 
377
483
  it 'should have an unchanged URI' do
378
- @request.uri.should == URI.parse('http://njonsson@github.com' +
484
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
379
485
  ':123' +
380
486
  '/search/deep?q=http&lang=en' +
381
487
  '#content')
382
488
  end
383
489
 
384
- it_should_behave_like 'an empty request'
490
+ it_should_behave_like 'an empty, authenticated request'
385
491
  end
386
492
 
387
493
  describe 'a different host --' do
@@ -390,13 +496,13 @@ describe HTTY::Request do
390
496
  end
391
497
 
392
498
  it 'should have the same URI, with the changed scheme' do
393
- @request.uri.should == URI.parse('http://' +
499
+ @request.uri.should == URI.parse('https://' +
394
500
  'njonsson@gist.github.com:123' +
395
501
  '/search/deep?q=http&lang=en' +
396
502
  '#content')
397
503
  end
398
504
 
399
- it_should_behave_like 'an empty request'
505
+ it_should_behave_like 'an empty, authenticated request'
400
506
  end
401
507
  end
402
508
 
@@ -407,13 +513,13 @@ describe HTTY::Request do
407
513
  end
408
514
 
409
515
  it 'should have an unchanged URI' do
410
- @request.uri.should == URI.parse('http://njonsson@github.com' +
516
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
411
517
  ':123' +
412
518
  '/search/deep?q=http&lang=en' +
413
519
  '#content')
414
520
  end
415
521
 
416
- it_should_behave_like 'an empty request'
522
+ it_should_behave_like 'an empty, authenticated request'
417
523
  end
418
524
 
419
525
  describe 'a different port --' do
@@ -422,13 +528,13 @@ describe HTTY::Request do
422
528
  end
423
529
 
424
530
  it 'should have the same URI, with the changed scheme' do
425
- @request.uri.should == URI.parse('http://njonsson@github.com' +
531
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
426
532
  ':8888' +
427
533
  '/search/deep?q=http&lang=en' +
428
534
  '#content')
429
535
  end
430
536
 
431
- it_should_behave_like 'an empty request'
537
+ it_should_behave_like 'an empty, authenticated request'
432
538
  end
433
539
  end
434
540
 
@@ -439,13 +545,13 @@ describe HTTY::Request do
439
545
  end
440
546
 
441
547
  it 'should have the same URI, descending to the expected path' do
442
- @request.uri.should == URI.parse('http://njonsson@github.com' +
548
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
443
549
  ':123' +
444
550
  '/search/deep/foo' +
445
551
  '?q=http&lang=en#content')
446
552
  end
447
553
 
448
- it_should_behave_like 'an empty request'
554
+ it_should_behave_like 'an empty, authenticated request'
449
555
  end
450
556
 
451
557
  describe 'a parent reference --' do
@@ -454,12 +560,12 @@ describe HTTY::Request do
454
560
  end
455
561
 
456
562
  it 'should have the same URI, ascending to the expected path' do
457
- @request.uri.should == URI.parse('http://njonsson@github.com' +
563
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
458
564
  ':123' +
459
565
  '/search?q=http&lang=en#content')
460
566
  end
461
567
 
462
- it_should_behave_like 'an empty request'
568
+ it_should_behave_like 'an empty, authenticated request'
463
569
  end
464
570
 
465
571
  describe 'an absolute reference --' do
@@ -468,13 +574,13 @@ describe HTTY::Request do
468
574
  end
469
575
 
470
576
  it 'should have the same URI, changing to the expected path' do
471
- @request.uri.should == URI.parse('http://njonsson@github.com' +
577
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
472
578
  ':123' +
473
579
  '/foo/bar?q=http&lang=en' +
474
580
  '#content')
475
581
  end
476
582
 
477
- it_should_behave_like 'an empty request'
583
+ it_should_behave_like 'an empty, authenticated request'
478
584
  end
479
585
  end
480
586
 
@@ -485,14 +591,14 @@ describe HTTY::Request do
485
591
  end
486
592
 
487
593
  it 'should have a URI including the new query parameter' do
488
- @request.uri.should == URI.parse('http://njonsson@github.com' +
594
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
489
595
  ':123' +
490
596
  '/search/deep' +
491
597
  '?q=http&lang=en&foo=bar' +
492
598
  '#content')
493
599
  end
494
600
 
495
- it_should_behave_like 'an empty request'
601
+ it_should_behave_like 'an empty, authenticated request'
496
602
  end
497
603
 
498
604
  describe 'with a new value for the first query parameter --' do
@@ -501,13 +607,13 @@ describe HTTY::Request do
501
607
  end
502
608
 
503
609
  it 'should have a URI with the new value of the query parameter' do
504
- @request.uri.should == URI.parse('http://njonsson@github.com' +
610
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
505
611
  ':123' +
506
612
  '/search/deep?q=ruby&lang=en' +
507
613
  '#content')
508
614
  end
509
615
 
510
- it_should_behave_like 'an empty request'
616
+ it_should_behave_like 'an empty, authenticated request'
511
617
  end
512
618
 
513
619
  describe 'with a new value for the second query parameter --' do
@@ -517,13 +623,13 @@ describe HTTY::Request do
517
623
 
518
624
  it 'should have a URI with the new value of the second query ' +
519
625
  'parameter' do
520
- @request.uri.should == URI.parse('http://njonsson@github.com' +
626
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
521
627
  ':123' +
522
628
  '/search/deep?q=http&lang=fr' +
523
629
  '#content')
524
630
  end
525
631
 
526
- it_should_behave_like 'an empty request'
632
+ it_should_behave_like 'an empty, authenticated request'
527
633
  end
528
634
  end
529
635
 
@@ -534,13 +640,13 @@ describe HTTY::Request do
534
640
  end
535
641
 
536
642
  it 'should have an unchanged URI' do
537
- @request.uri.should == URI.parse('http://njonsson@github.com' +
643
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
538
644
  ':123' +
539
645
  '/search/deep?q=http&lang=en' +
540
646
  '#content')
541
647
  end
542
648
 
543
- it_should_behave_like 'an empty request'
649
+ it_should_behave_like 'an empty, authenticated request'
544
650
  end
545
651
 
546
652
  describe 'with the first query parameter --' do
@@ -549,12 +655,12 @@ describe HTTY::Request do
549
655
  end
550
656
 
551
657
  it 'should have a URI missing the first query parameter' do
552
- @request.uri.should == URI.parse('http://njonsson@github.com' +
658
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
553
659
  ':123' +
554
660
  '/search/deep?lang=en#content')
555
661
  end
556
662
 
557
- it_should_behave_like 'an empty request'
663
+ it_should_behave_like 'an empty, authenticated request'
558
664
  end
559
665
 
560
666
  describe 'with the second query parameter --' do
@@ -563,12 +669,12 @@ describe HTTY::Request do
563
669
  end
564
670
 
565
671
  it 'should have a URI missing the second query parameter' do
566
- @request.uri.should == URI.parse('http://njonsson@github.com' +
672
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
567
673
  ':123' +
568
674
  '/search/deep?q=http#content')
569
675
  end
570
676
 
571
- it_should_behave_like 'an empty request'
677
+ it_should_behave_like 'an empty, authenticated request'
572
678
  end
573
679
  end
574
680
 
@@ -578,11 +684,11 @@ describe HTTY::Request do
578
684
  end
579
685
 
580
686
  it 'should have a URI having no query string' do
581
- @request.uri.should == URI.parse('http://njonsson@github.com:123' +
687
+ @request.uri.should == URI.parse('https://njonsson@github.com:123' +
582
688
  '/search/deep#content')
583
689
  end
584
690
 
585
- it_should_behave_like 'an empty request'
691
+ it_should_behave_like 'an empty, authenticated request'
586
692
  end
587
693
 
588
694
  describe '-- when sent #fragment_set with' do
@@ -592,13 +698,13 @@ describe HTTY::Request do
592
698
  end
593
699
 
594
700
  it 'should have an unchanged URI' do
595
- @request.uri.should == URI.parse('http://njonsson@github.com' +
701
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
596
702
  ':123' +
597
703
  '/search/deep?q=http&lang=en' +
598
704
  '#content')
599
705
  end
600
706
 
601
- it_should_behave_like 'an empty request'
707
+ it_should_behave_like 'an empty, authenticated request'
602
708
  end
603
709
 
604
710
  describe 'different fragment --' do
@@ -607,13 +713,13 @@ describe HTTY::Request do
607
713
  end
608
714
 
609
715
  it 'should have the same URI, with the changed fragment' do
610
- @request.uri.should == URI.parse('http://njonsson@github.com' +
716
+ @request.uri.should == URI.parse('https://njonsson@github.com' +
611
717
  ':123' +
612
718
  '/search/deep?q=http&lang=en' +
613
719
  '#details')
614
720
  end
615
721
 
616
- it_should_behave_like 'an empty request'
722
+ it_should_behave_like 'an empty, authenticated request'
617
723
  end
618
724
  end
619
725
 
@@ -623,11 +729,11 @@ describe HTTY::Request do
623
729
  end
624
730
 
625
731
  it 'should have the same URI, without fragment' do
626
- @request.uri.should == URI.parse('http://njonsson@github.com:123' +
732
+ @request.uri.should == URI.parse('https://njonsson@github.com:123' +
627
733
  '/search/deep?q=http&lang=en')
628
734
  end
629
735
 
630
- it_should_behave_like 'an empty request'
736
+ it_should_behave_like 'an empty, authenticated request'
631
737
  end
632
738
 
633
739
  describe '-- when sent #header_set with a new header' do
@@ -636,15 +742,17 @@ describe HTTY::Request do
636
742
  end
637
743
 
638
744
  it 'should have an unchanged URI' do
639
- @request.uri.should == URI.parse('http://njonsson@github.com:123' +
640
- '/search/deep?q=http&lang=en' +
745
+ @request.uri.should == URI.parse('https://njonsson@github.com:123' +
746
+ '/search/deep?q=http&lang=en' +
641
747
  '#content')
642
748
  end
643
749
 
644
750
  describe '--' do
645
751
  it 'should have the header, plus the default headers' do
646
- @request.headers.should == [%w(User-Agent htty/1.0.0),
647
- %w(foo bar)]
752
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
753
+ ['Authorization', 'Basic ' +
754
+ 'bmpvbnNzb24='],
755
+ ['foo', 'bar']]
648
756
  end
649
757
  end
650
758
 
@@ -655,7 +763,9 @@ describe HTTY::Request do
655
763
  end
656
764
 
657
765
  it 'should have only the default headers' do
658
- @request.headers.should == [%w(User-Agent htty/1.0.0)]
766
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
767
+ ['Authorization', 'Basic ' +
768
+ 'bmpvbnNzb24=']]
659
769
  end
660
770
  end
661
771
 
@@ -665,8 +775,10 @@ describe HTTY::Request do
665
775
  end
666
776
 
667
777
  it 'should have the header, plus the default headers' do
668
- @request.headers.should == [%w(User-Agent htty/1.0.0),
669
- %w(foo bar)]
778
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
779
+ ['Authorization', 'Basic ' +
780
+ 'bmpvbnNzb24='],
781
+ ['foo', 'bar']]
670
782
  end
671
783
  end
672
784
  end
@@ -688,8 +800,8 @@ describe HTTY::Request do
688
800
  end
689
801
 
690
802
  it 'should have an unchanged URI' do
691
- @request.uri.should == URI.parse('http://njonsson@github.com:123' +
692
- '/search/deep?q=http&lang=en' +
803
+ @request.uri.should == URI.parse('https://njonsson@github.com:123' +
804
+ '/search/deep?q=http&lang=en' +
693
805
  '#content')
694
806
  end
695
807
 
@@ -699,8 +811,10 @@ describe HTTY::Request do
699
811
  end
700
812
 
701
813
  it 'should have the cookie header, plus the default headers' do
702
- @request.headers.should == [%w(User-Agent htty/1.0.0),
703
- %w(Cookie foo=bar)]
814
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
815
+ ['Authorization', 'Basic ' +
816
+ 'bmpvbnNzb24='],
817
+ ['Cookie', 'foo=bar']]
704
818
  end
705
819
  end
706
820
 
@@ -716,8 +830,11 @@ describe HTTY::Request do
716
830
 
717
831
  it 'should have the new cookie header, plus the default ' +
718
832
  'headers' do
719
- @request.headers.should == [['User-Agent', 'htty/1.0.0'],
720
- ['Cookie', 'foo=bar; foo=qux']]
833
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
834
+ ['Authorization', 'Basic ' +
835
+ 'bmpvbnNzb24='],
836
+ ['Cookie', 'foo=bar; ' +
837
+ 'foo=qux']]
721
838
  end
722
839
  end
723
840
 
@@ -732,8 +849,11 @@ describe HTTY::Request do
732
849
 
733
850
  it 'should have the new cookie header, plus the default ' +
734
851
  'headers' do
735
- @request.headers.should == [['User-Agent', 'htty/1.0.0'],
736
- ['Cookie', 'foo=bar; baz=qux']]
852
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
853
+ ['Authorization', 'Basic ' +
854
+ 'bmpvbnNzb24='],
855
+ ['Cookie', 'foo=bar; ' +
856
+ 'baz=qux']]
737
857
  end
738
858
  end
739
859
 
@@ -748,8 +868,10 @@ describe HTTY::Request do
748
868
 
749
869
  it 'should have the new cookie header, plus the default ' +
750
870
  'headers' do
751
- @request.headers.should == [['User-Agent', 'htty/1.0.0'],
752
- ['Cookie', 'foo=bar; baz']]
871
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
872
+ ['Authorization', 'Basic ' +
873
+ 'bmpvbnNzb24='],
874
+ ['Cookie', 'foo=bar; baz']]
753
875
  end
754
876
  end
755
877
  end
@@ -765,7 +887,9 @@ describe HTTY::Request do
765
887
  end
766
888
 
767
889
  it 'should have only the default headers' do
768
- @request.headers.should == [%w(User-Agent htty/1.0.0)]
890
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
891
+ ['Authorization', 'Basic ' +
892
+ 'bmpvbnNzb24=']]
769
893
  end
770
894
  end
771
895
 
@@ -779,8 +903,10 @@ describe HTTY::Request do
779
903
  end
780
904
 
781
905
  it 'should have the cookie header, plus the default headers' do
782
- @request.headers.should == [%w(User-Agent htty/1.0.0),
783
- %w(Cookie foo=bar)]
906
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
907
+ ['Authorization', 'Basic ' +
908
+ 'bmpvbnNzb24='],
909
+ ['Cookie', 'foo=bar']]
784
910
  end
785
911
  end
786
912
  end
@@ -795,7 +921,9 @@ describe HTTY::Request do
795
921
  end
796
922
 
797
923
  it 'should have only the default headers' do
798
- @request.headers.should == [%w(User-Agent htty/1.0.0)]
924
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
925
+ ['Authorization', 'Basic ' +
926
+ 'bmpvbnNzb24=']]
799
927
  end
800
928
  end
801
929
 
@@ -810,7 +938,7 @@ describe HTTY::Request do
810
938
  end
811
939
 
812
940
  it 'should have the cookie header, plus the default headers' do
813
- @request.headers.should == [%w(User-Agent htty/1.0.0),
941
+ @request.headers.should == [%w(User-Agent htty/1.1.0),
814
942
  %w(Cookie foo=bar)]
815
943
  end
816
944
  end
@@ -826,7 +954,7 @@ describe HTTY::Request do
826
954
  end
827
955
 
828
956
  it 'should have only the default headers' do
829
- @request.headers.should == [%w(User-Agent htty/1.0.0)]
957
+ @request.headers.should == [%w(User-Agent htty/1.1.0)]
830
958
  end
831
959
  end
832
960
  end
@@ -843,8 +971,10 @@ describe HTTY::Request do
843
971
  end
844
972
 
845
973
  it 'should have the cookie header, plus the default headers' do
846
- @request.headers.should == [%w(User-Agent htty/1.0.0),
847
- %w(Cookie foo=bar=baz=qux)]
974
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
975
+ ['Authorization', 'Basic ' +
976
+ 'bmpvbnNzb24='],
977
+ ['Cookie', 'foo=bar=baz=qux']]
848
978
  end
849
979
  end
850
980
  end
@@ -855,8 +985,8 @@ describe HTTY::Request do
855
985
  end
856
986
 
857
987
  it 'should have an unchanged URI' do
858
- @request.uri.should == URI.parse('http://njonsson@github.com:123' +
859
- '/search/deep?q=http&lang=en' +
988
+ @request.uri.should == URI.parse('https://njonsson@github.com:123' +
989
+ '/search/deep?q=http&lang=en' +
860
990
  '#content')
861
991
  end
862
992
 
@@ -866,14 +996,20 @@ describe HTTY::Request do
866
996
  end
867
997
 
868
998
  it 'should have only the default headers' do
869
- @request.headers.should == [%w(User-Agent htty/1.0.0)]
999
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
1000
+ ['Authorization', 'Basic ' +
1001
+ 'bmpvbnNzb24=']]
870
1002
  end
871
1003
 
872
1004
  it "should have the expected 'Content-Length' header, plus the " +
873
1005
  "'User-Agent' header if we do not exclude the " +
874
1006
  "'Content-Length' header" do
875
- @request.headers(true).should == [%w(User-Agent htty/1.0.0),
876
- %w(Content-Length 3)]
1007
+ @request.headers(true).should == [['User-Agent', 'htty/' +
1008
+ '1.1.0'],
1009
+ ['Authorization', 'Basic ' +
1010
+ 'bmpvbnNz' +
1011
+ 'b24='],
1012
+ ['Content-Length', '3']]
877
1013
  end
878
1014
  end
879
1015
 
@@ -887,7 +1023,9 @@ describe HTTY::Request do
887
1023
  end
888
1024
 
889
1025
  it 'should have only the default headers' do
890
- @request.headers.should == [%w(User-Agent htty/1.0.0)]
1026
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
1027
+ ['Authorization', 'Basic ' +
1028
+ 'bmpvbnNzb24=']]
891
1029
  end
892
1030
  end
893
1031
  end
@@ -900,13 +1038,15 @@ describe HTTY::Request do
900
1038
  end
901
1039
 
902
1040
  it 'should not affect the URI' do
903
- @request.uri.should == URI.parse('http://njonsson@github.com:123' +
904
- '/search/deep?q=http&lang=en' +
1041
+ @request.uri.should == URI.parse('https://njonsson@github.com:123' +
1042
+ '/search/deep?q=http&lang=en' +
905
1043
  '#content')
906
1044
  end
907
1045
 
908
1046
  it 'should not affect the headers' do
909
- @request.headers.should == [%w(User-Agent htty/1.0.0)]
1047
+ @request.headers.should == [['User-Agent', 'htty/1.1.0'],
1048
+ ['Authorization', 'Basic ' +
1049
+ 'bmpvbnNzb24=']]
910
1050
  end
911
1051
 
912
1052
  it 'should not affect the body' do
@@ -956,10 +1096,10 @@ describe HTTY::Request do
956
1096
 
957
1097
  it 'should return a request with the same URI having the changed ' +
958
1098
  'userinfo' do
959
- @new_request.uri.should == URI.parse('http://nils@github.com' +
960
- ':123' +
961
- '/search/deep' +
962
- '?q=http&lang=en' +
1099
+ @new_request.uri.should == URI.parse('https://nils@github.com' +
1100
+ ':123' +
1101
+ '/search/deep' +
1102
+ '?q=http&lang=en' +
963
1103
  '#content')
964
1104
  end
965
1105
 
@@ -974,7 +1114,7 @@ describe HTTY::Request do
974
1114
  end
975
1115
 
976
1116
  it 'should return a request with the same URI not having userinfo' do
977
- @new_request.uri.should == URI.parse('http://github.com:123' +
1117
+ @new_request.uri.should == URI.parse('https://github.com:123' +
978
1118
  '/search/deep?q=http&lang=en' +
979
1119
  '#content')
980
1120
  end
@@ -991,7 +1131,7 @@ describe HTTY::Request do
991
1131
 
992
1132
  it 'should return a request with the same URI having the changed ' +
993
1133
  'host' do
994
- @new_request.uri.should == URI.parse('http://' +
1134
+ @new_request.uri.should == URI.parse('https://' +
995
1135
  'njonsson@gist.github.com' +
996
1136
  ':123' +
997
1137
  '/search/deep?q=http&lang=en' +
@@ -1010,7 +1150,7 @@ describe HTTY::Request do
1010
1150
 
1011
1151
  it 'should return a request with the same URI having the changed ' +
1012
1152
  'port' do
1013
- @new_request.uri.should == URI.parse('http://njonsson@github.com' +
1153
+ @new_request.uri.should == URI.parse('https://njonsson@github.com' +
1014
1154
  ':8888' +
1015
1155
  '/search/deep?q=http&lang=en' +
1016
1156
  '#content')
@@ -1028,7 +1168,7 @@ describe HTTY::Request do
1028
1168
 
1029
1169
  it 'should return a request with the same URI having the changed ' +
1030
1170
  'path' do
1031
- @new_request.uri.should == URI.parse('http://njonsson@github.com' +
1171
+ @new_request.uri.should == URI.parse('https://njonsson@github.com' +
1032
1172
  ':123' +
1033
1173
  '/search/deep/foo' +
1034
1174
  '?q=http&lang=en#content')
@@ -1046,7 +1186,7 @@ describe HTTY::Request do
1046
1186
 
1047
1187
  it 'should return a request with the same URI having the new query ' +
1048
1188
  'parameter' do
1049
- @new_request.uri.should == URI.parse('http://njonsson@github.com' +
1189
+ @new_request.uri.should == URI.parse('https://njonsson@github.com' +
1050
1190
  ':123' +
1051
1191
  '/search/deep' +
1052
1192
  '?q=http&lang=en&foo=bar' +
@@ -1066,7 +1206,7 @@ describe HTTY::Request do
1066
1206
 
1067
1207
  it 'should return a request with the same URI missing the first ' +
1068
1208
  'query parameter' do
1069
- @new_request.uri.should == URI.parse('http://njonsson@github.com' +
1209
+ @new_request.uri.should == URI.parse('https://njonsson@github.com' +
1070
1210
  ':123' +
1071
1211
  '/search/deep?lang=en#content')
1072
1212
  end
@@ -1083,7 +1223,7 @@ describe HTTY::Request do
1083
1223
 
1084
1224
  it 'should return a request with the same URI having no query ' +
1085
1225
  'string' do
1086
- @new_request.uri.should == URI.parse('http://' +
1226
+ @new_request.uri.should == URI.parse('https://' +
1087
1227
  'njonsson@github.com:123' +
1088
1228
  '/search/deep#content')
1089
1229
  end
@@ -1100,7 +1240,7 @@ describe HTTY::Request do
1100
1240
 
1101
1241
  it 'should return a request with the same URI having the changed ' +
1102
1242
  'fragment' do
1103
- @new_request.uri.should == URI.parse('http://njonsson@github.com' +
1243
+ @new_request.uri.should == URI.parse('https://njonsson@github.com' +
1104
1244
  ':123' +
1105
1245
  '/search/deep?q=http&lang=en' +
1106
1246
  '#details')
@@ -1117,7 +1257,7 @@ describe HTTY::Request do
1117
1257
  end
1118
1258
 
1119
1259
  it 'should return a request with the same URI missing the fragment' do
1120
- @new_request.uri.should == URI.parse('http://' +
1260
+ @new_request.uri.should == URI.parse('https://' +
1121
1261
  'njonsson@github.com:123' +
1122
1262
  '/search/deep?q=http&lang=en')
1123
1263
  end
@@ -1133,7 +1273,7 @@ describe HTTY::Request do
1133
1273
  end
1134
1274
 
1135
1275
  it 'should return a request with an unchanged URI' do
1136
- @new_request.uri.should == URI.parse('http://' +
1276
+ @new_request.uri.should == URI.parse('https://' +
1137
1277
  'njonsson@github.com:123' +
1138
1278
  '/search/deep?q=http&lang=en' +
1139
1279
  '#content')
@@ -1146,8 +1286,10 @@ describe HTTY::Request do
1146
1286
  describe '--' do
1147
1287
  it 'should return a request with the header, plus the default ' +
1148
1288
  'headers' do
1149
- @new_request.headers.should == [%w(User-Agent htty/1.0.0),
1150
- %w(foo bar)]
1289
+ @new_request.headers.should == [['User-Agent', 'htty/1.1.0'],
1290
+ ['Authorization', 'Basic ' +
1291
+ 'bmpvbnNzb24='],
1292
+ ['foo', 'bar']]
1151
1293
  end
1152
1294
 
1153
1295
  it 'should return a request without a response' do
@@ -1162,7 +1304,10 @@ describe HTTY::Request do
1162
1304
  end
1163
1305
 
1164
1306
  it 'should return a request with only the default headers' do
1165
- @new_request.headers.should == [%w(User-Agent htty/1.0.0)]
1307
+ @new_request.headers.should == [['User-Agent', 'htty/1.1.0'],
1308
+ ['Authorization', 'Basic ' +
1309
+ 'bmpvbnNzb2' +
1310
+ '4=']]
1166
1311
  end
1167
1312
  end
1168
1313
  end
@@ -1184,7 +1329,7 @@ describe HTTY::Request do
1184
1329
  end
1185
1330
 
1186
1331
  it 'should return a request with an unchanged URI' do
1187
- @new_request.uri.should == URI.parse('http://' +
1332
+ @new_request.uri.should == URI.parse('https://' +
1188
1333
  'njonsson@github.com:123' +
1189
1334
  '/search/deep?q=http&lang=en' +
1190
1335
  '#content')
@@ -1200,14 +1345,20 @@ describe HTTY::Request do
1200
1345
  end
1201
1346
 
1202
1347
  it 'should return a request with only the default headers' do
1203
- @new_request.headers.should == [%w(User-Agent htty/1.0.0)]
1348
+ @new_request.headers.should == [['User-Agent', 'htty/1.1.0'],
1349
+ ['Authorization', 'Basic ' +
1350
+ 'bmpvbnNzb2' +
1351
+ '4=']]
1204
1352
  end
1205
1353
 
1206
1354
  it "should return a request with the expected 'Content-Length' " +
1207
1355
  "header, plus the 'User-Agent' header if we do not exclude " +
1208
1356
  "the 'Content-Length' header" do
1209
- @new_request.headers(true).should == [['User-Agent', 'htty/' +
1210
- '1.0.0'],
1357
+ @new_request.headers(true).should == [['User-Agent', 'htty/' +
1358
+ '1.1.0'],
1359
+ ['Authorization', 'Basic ' +
1360
+ 'bmpvbn' +
1361
+ 'Nzb24='],
1211
1362
  ['Content-Length', '3']]
1212
1363
  end
1213
1364
 
@@ -1226,7 +1377,10 @@ describe HTTY::Request do
1226
1377
  end
1227
1378
 
1228
1379
  it 'should return a request with only the default headers' do
1229
- @new_request.headers.should == [%w(User-Agent htty/1.0.0)]
1380
+ @new_request.headers.should == [['User-Agent', 'htty/1.1.0'],
1381
+ ['Authorization', 'Basic ' +
1382
+ 'bmpvbnNzb2' +
1383
+ '4=']]
1230
1384
  end
1231
1385
  end
1232
1386
  end