htty 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/MIT-LICENSE.rdoc +9 -0
  2. data/README.rdoc +199 -0
  3. data/VERSION +1 -0
  4. data/app/htty.rb +14 -0
  5. data/app/htty/cli.rb +77 -0
  6. data/app/htty/cli/command.rb +185 -0
  7. data/app/htty/cli/commands.rb +43 -0
  8. data/app/htty/cli/commands/address.rb +84 -0
  9. data/app/htty/cli/commands/body_clear.rb +20 -0
  10. data/app/htty/cli/commands/body_request.rb +51 -0
  11. data/app/htty/cli/commands/body_response.rb +59 -0
  12. data/app/htty/cli/commands/body_set.rb +58 -0
  13. data/app/htty/cli/commands/body_unset.rb +45 -0
  14. data/app/htty/cli/commands/cd.rb +20 -0
  15. data/app/htty/cli/commands/cookie_add.rb +20 -0
  16. data/app/htty/cli/commands/cookie_remove.rb +20 -0
  17. data/app/htty/cli/commands/cookies.rb +68 -0
  18. data/app/htty/cli/commands/cookies_add.rb +62 -0
  19. data/app/htty/cli/commands/cookies_clear.rb +20 -0
  20. data/app/htty/cli/commands/cookies_remove.rb +60 -0
  21. data/app/htty/cli/commands/cookies_remove_all.rb +50 -0
  22. data/app/htty/cli/commands/cookies_use.rb +57 -0
  23. data/app/htty/cli/commands/delete.rb +20 -0
  24. data/app/htty/cli/commands/exit.rb +20 -0
  25. data/app/htty/cli/commands/follow.rb +56 -0
  26. data/app/htty/cli/commands/form.rb +20 -0
  27. data/app/htty/cli/commands/form_add.rb +20 -0
  28. data/app/htty/cli/commands/form_clear.rb +26 -0
  29. data/app/htty/cli/commands/form_remove.rb +20 -0
  30. data/app/htty/cli/commands/form_remove_all.rb +20 -0
  31. data/app/htty/cli/commands/fragment_clear.rb +20 -0
  32. data/app/htty/cli/commands/fragment_set.rb +59 -0
  33. data/app/htty/cli/commands/fragment_unset.rb +48 -0
  34. data/app/htty/cli/commands/get.rb +20 -0
  35. data/app/htty/cli/commands/header_set.rb +20 -0
  36. data/app/htty/cli/commands/header_unset.rb +20 -0
  37. data/app/htty/cli/commands/headers_clear.rb +20 -0
  38. data/app/htty/cli/commands/headers_request.rb +70 -0
  39. data/app/htty/cli/commands/headers_response.rb +65 -0
  40. data/app/htty/cli/commands/headers_set.rb +57 -0
  41. data/app/htty/cli/commands/headers_unset.rb +54 -0
  42. data/app/htty/cli/commands/headers_unset_all.rb +48 -0
  43. data/app/htty/cli/commands/help.rb +100 -0
  44. data/app/htty/cli/commands/history.rb +60 -0
  45. data/app/htty/cli/commands/history_verbose.rb +81 -0
  46. data/app/htty/cli/commands/host_set.rb +59 -0
  47. data/app/htty/cli/commands/http_delete.rb +40 -0
  48. data/app/htty/cli/commands/http_get.rb +42 -0
  49. data/app/htty/cli/commands/http_head.rb +36 -0
  50. data/app/htty/cli/commands/http_options.rb +36 -0
  51. data/app/htty/cli/commands/http_post.rb +34 -0
  52. data/app/htty/cli/commands/http_put.rb +29 -0
  53. data/app/htty/cli/commands/http_trace.rb +36 -0
  54. data/app/htty/cli/commands/path_set.rb +54 -0
  55. data/app/htty/cli/commands/port_set.rb +55 -0
  56. data/app/htty/cli/commands/post.rb +20 -0
  57. data/app/htty/cli/commands/put.rb +20 -0
  58. data/app/htty/cli/commands/query_clear.rb +20 -0
  59. data/app/htty/cli/commands/query_set.rb +59 -0
  60. data/app/htty/cli/commands/query_unset.rb +56 -0
  61. data/app/htty/cli/commands/query_unset_all.rb +50 -0
  62. data/app/htty/cli/commands/quit.rb +24 -0
  63. data/app/htty/cli/commands/reuse.rb +74 -0
  64. data/app/htty/cli/commands/scheme_set.rb +69 -0
  65. data/app/htty/cli/commands/status.rb +52 -0
  66. data/app/htty/cli/commands/undo.rb +13 -0
  67. data/app/htty/cli/commands/userinfo_clear.rb +20 -0
  68. data/app/htty/cli/commands/userinfo_set.rb +56 -0
  69. data/app/htty/cli/commands/userinfo_unset.rb +47 -0
  70. data/app/htty/cli/cookie_clearing_command.rb +26 -0
  71. data/app/htty/cli/display.rb +182 -0
  72. data/app/htty/cli/http_method_command.rb +75 -0
  73. data/app/htty/cli/url_escaping.rb +27 -0
  74. data/app/htty/cookies_util.rb +36 -0
  75. data/app/htty/no_location_header_error.rb +12 -0
  76. data/app/htty/no_response_error.rb +12 -0
  77. data/app/htty/no_set_cookie_header_error.rb +13 -0
  78. data/app/htty/ordered_hash.rb +69 -0
  79. data/app/htty/payload.rb +48 -0
  80. data/app/htty/request.rb +471 -0
  81. data/app/htty/requests_util.rb +92 -0
  82. data/app/htty/response.rb +34 -0
  83. data/app/htty/session.rb +29 -0
  84. data/bin/htty +5 -0
  85. data/spec/unit/htty/cli_spec.rb +27 -0
  86. data/spec/unit/htty/ordered_hash_spec.rb +54 -0
  87. data/spec/unit/htty/request_spec.rb +1236 -0
  88. data/spec/unit/htty/response_spec.rb +0 -0
  89. data/spec/unit/htty/session_spec.rb +13 -0
  90. metadata +158 -0
@@ -0,0 +1,36 @@
1
+ # Defines HTTY::CLI::Commands::HttpOptions.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/../http_method_command")
5
+ require File.expand_path("#{File.dirname __FILE__}/http_get")
6
+
7
+ module HTTY; end
8
+
9
+ class HTTY::CLI; end
10
+
11
+ module HTTY::CLI::Commands; end
12
+
13
+ # Encapsulates the _http-options_ command.
14
+ class HTTY::CLI::Commands::HttpOptions < HTTY::CLI::Command
15
+
16
+ include HTTY::CLI::HTTPMethodCommand
17
+
18
+ # Returns the help text for the _http-options_ command.
19
+ def self.help
20
+ 'Issues an HTTP OPTIONS using the current request'
21
+ end
22
+
23
+ # Returns the extended help text for the _http-options_ command.
24
+ def self.help_extended
25
+ "Issues an HTTP OPTIONS using the current request.\n" +
26
+ "\n" +
27
+ 'Any request body you may set is ignored (i.e., it is not sent as part ' +
28
+ 'of the request).'
29
+ end
30
+
31
+ # Returns related command classes for the _http-options_ command.
32
+ def self.see_also_commands
33
+ [HTTY::CLI::Commands::HttpGet]
34
+ end
35
+
36
+ end
@@ -0,0 +1,34 @@
1
+ # Defines HTTY::CLI::Commands::HttpPost.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/../http_method_command")
5
+ require File.expand_path("#{File.dirname __FILE__}/follow")
6
+ require File.expand_path("#{File.dirname __FILE__}/http_delete")
7
+ require File.expand_path("#{File.dirname __FILE__}/http_get")
8
+ require File.expand_path("#{File.dirname __FILE__}/http_put")
9
+
10
+ module HTTY; end
11
+
12
+ class HTTY::CLI; end
13
+
14
+ module HTTY::CLI::Commands; end
15
+
16
+ # Encapsulates the _http-post_ command.
17
+ class HTTY::CLI::Commands::HttpPost < HTTY::CLI::Command
18
+
19
+ include HTTY::CLI::HTTPMethodCommand
20
+
21
+ # Returns the help text for the _http-post_ command.
22
+ def self.help
23
+ 'Issues an HTTP POST using the current request'
24
+ end
25
+
26
+ # Returns related command classes for the _http-post_ command.
27
+ def self.see_also_commands
28
+ [HTTY::CLI::Commands::HttpGet,
29
+ HTTY::CLI::Commands::Follow,
30
+ HTTY::CLI::Commands::HttpPut,
31
+ HTTY::CLI::Commands::HttpDelete]
32
+ end
33
+
34
+ end
@@ -0,0 +1,29 @@
1
+ # Defines HTTY::CLI::Commands::HttpPut.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/../http_method_command")
5
+
6
+ module HTTY; end
7
+
8
+ class HTTY::CLI; end
9
+
10
+ module HTTY::CLI::Commands; end
11
+
12
+ # Encapsulates the _http-put_ command.
13
+ class HTTY::CLI::Commands::HttpPut < HTTY::CLI::Command
14
+
15
+ include HTTY::CLI::HTTPMethodCommand
16
+
17
+ # Returns the help text for the _http-put_ command.
18
+ def self.help
19
+ 'Issues an HTTP PUT using the current request'
20
+ end
21
+
22
+ # Returns related command classes for the _http-put_ command.
23
+ def self.see_also_commands
24
+ [HTTY::CLI::Commands::HttpGet,
25
+ HTTY::CLI::Commands::HttpPost,
26
+ HTTY::CLI::Commands::HttpDelete]
27
+ end
28
+
29
+ end
@@ -0,0 +1,36 @@
1
+ # Defines HTTY::CLI::Commands::HttpTrace.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/../http_method_command")
5
+ require File.expand_path("#{File.dirname __FILE__}/http_get")
6
+
7
+ module HTTY; end
8
+
9
+ class HTTY::CLI; end
10
+
11
+ module HTTY::CLI::Commands; end
12
+
13
+ # Encapsulates the _http-trace_ command.
14
+ class HTTY::CLI::Commands::HttpTrace < HTTY::CLI::Command
15
+
16
+ include HTTY::CLI::HTTPMethodCommand
17
+
18
+ # Returns the help text for the _http-trace_ command.
19
+ def self.help
20
+ 'Issues an HTTP TRACE using the current request'
21
+ end
22
+
23
+ # Returns the extended help text for the _http-trace_ command.
24
+ def self.help_extended
25
+ "Issues an HTTP TRACE using the current request.\n" +
26
+ "\n" +
27
+ 'Any request body you may set is ignored (i.e., it is not sent as part ' +
28
+ 'of the request).'
29
+ end
30
+
31
+ # Returns related command classes for the _http-trace_ command.
32
+ def self.see_also_commands
33
+ [HTTY::CLI::Commands::HttpGet]
34
+ end
35
+
36
+ end
@@ -0,0 +1,54 @@
1
+ # Defines HTTY::CLI::Commands::PathSet.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/../url_escaping")
5
+ require File.expand_path("#{File.dirname __FILE__}/address")
6
+
7
+ module HTTY; end
8
+
9
+ class HTTY::CLI; end
10
+
11
+ module HTTY::CLI::Commands; end
12
+
13
+ # Encapsulates the _path-set_ command.
14
+ class HTTY::CLI::Commands::PathSet < HTTY::CLI::Command
15
+
16
+ include HTTY::CLI::UrlEscaping
17
+
18
+ # Returns the name of a category under which help for the _path-set_ command
19
+ # should appear.
20
+ def self.category
21
+ 'Navigation'
22
+ end
23
+
24
+ # Returns the arguments for the command-line usage of the _path-set_ command.
25
+ def self.command_line_arguments
26
+ 'path'
27
+ end
28
+
29
+ # Returns the help text for the _path-set_ command.
30
+ def self.help
31
+ "Changes the path of the request's address"
32
+ end
33
+
34
+ # Returns the extended help text for the _path-set_ command.
35
+ def self.help_extended
36
+ 'Changes the path used for the request. Does not communicate with the ' +
37
+ "endpoint.\n" +
38
+ "\n" +
39
+ 'The console prompt shows the address for the current request.'
40
+ end
41
+
42
+ # Returns related command classes for the _path-set_ command.
43
+ def self.see_also_commands
44
+ [HTTY::CLI::Commands::Address]
45
+ end
46
+
47
+ # Performs the _path-set_ command.
48
+ def perform
49
+ add_request_if_has_response do |request|
50
+ request.path_set(*escape_or_warn_of_escape_sequences(arguments))
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,55 @@
1
+ # Defines HTTY::CLI::Commands::PortSet.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/address")
5
+ require File.expand_path("#{File.dirname __FILE__}/scheme_set")
6
+
7
+ module HTTY; end
8
+
9
+ class HTTY::CLI; end
10
+
11
+ module HTTY::CLI::Commands; end
12
+
13
+ # Encapsulates the _port-set_ command.
14
+ class HTTY::CLI::Commands::PortSet < HTTY::CLI::Command
15
+
16
+ # Returns the name of a category under which help for the _port-set_ command
17
+ # should appear.
18
+ def self.category
19
+ 'Navigation'
20
+ end
21
+
22
+ # Returns the arguments for the command-line usage of the _port-set_ command.
23
+ def self.command_line_arguments
24
+ 'port'
25
+ end
26
+
27
+ # Returns the help text for the _port-set_ command.
28
+ def self.help
29
+ "Changes the TCP port of the request's address"
30
+ end
31
+
32
+ # Returns the extended help text for the _port-set_ command.
33
+ def self.help_extended
34
+ 'Changes the TCP port used for the request. Does not communicate with ' +
35
+ "the endpoint.\n" +
36
+ "\n" +
37
+ "The port you supply must be an integer between 0 and 65,535. Changing " +
38
+ "the port has no effect on the scheme, and vice versa.\n" +
39
+ "\n" +
40
+ 'The console prompt shows the address for the current request.'
41
+ end
42
+
43
+ # Returns related command classes for the _port-set_ command.
44
+ def self.see_also_commands
45
+ [HTTY::CLI::Commands::Address, HTTY::CLI::Commands::SchemeSet]
46
+ end
47
+
48
+ # Performs the _port-set_ command.
49
+ def perform
50
+ add_request_if_has_response do |request|
51
+ request.port_set(*arguments)
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,20 @@
1
+ # Defines HTTY::CLI::Commands::Post.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/http_post")
5
+
6
+ module HTTY; end
7
+
8
+ class HTTY::CLI; end
9
+
10
+ module HTTY::CLI::Commands; end
11
+
12
+ # Encapsulates the _post_ command.
13
+ class HTTY::CLI::Commands::Post < HTTY::CLI::Command
14
+
15
+ # Returns the command that the _post_ command is an alias for.
16
+ def self.alias_for
17
+ HTTY::CLI::Commands::HttpPost
18
+ end
19
+
20
+ end
@@ -0,0 +1,20 @@
1
+ # Defines HTTY::CLI::Commands::Put.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/http_put")
5
+
6
+ module HTTY; end
7
+
8
+ class HTTY::CLI; end
9
+
10
+ module HTTY::CLI::Commands; end
11
+
12
+ # Encapsulates the _put_ command.
13
+ class HTTY::CLI::Commands::Put < HTTY::CLI::Command
14
+
15
+ # Returns the command that the _put_ command is an alias for.
16
+ def self.alias_for
17
+ HTTY::CLI::Commands::HttpPut
18
+ end
19
+
20
+ end
@@ -0,0 +1,20 @@
1
+ # Defines HTTY::CLI::Commands::QueryClear.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/query_unset_all")
5
+
6
+ module HTTY; end
7
+
8
+ class HTTY::CLI; end
9
+
10
+ module HTTY::CLI::Commands; end
11
+
12
+ # Encapsulates the _query-clear_ command.
13
+ class HTTY::CLI::Commands::QueryClear < HTTY::CLI::Command
14
+
15
+ # Returns the command that the _query-clear_ command is an alias for.
16
+ def self.alias_for
17
+ HTTY::CLI::Commands::QueryUnsetAll
18
+ end
19
+
20
+ end
@@ -0,0 +1,59 @@
1
+ # Defines HTTY::CLI::Commands::QuerySet.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/../url_escaping")
5
+ require File.expand_path("#{File.dirname __FILE__}/address")
6
+ require File.expand_path("#{File.dirname __FILE__}/query_unset")
7
+ require File.expand_path("#{File.dirname __FILE__}/query_unset_all")
8
+
9
+ module HTTY; end
10
+
11
+ class HTTY::CLI; end
12
+
13
+ module HTTY::CLI::Commands; end
14
+
15
+ # Encapsulates the _query-set_ command.
16
+ class HTTY::CLI::Commands::QuerySet < HTTY::CLI::Command
17
+
18
+ include HTTY::CLI::UrlEscaping
19
+
20
+ # Returns the name of a category under which help for the _query-set_ command
21
+ # should appear.
22
+ def self.category
23
+ 'Navigation'
24
+ end
25
+
26
+ # Returns the arguments for the command-line usage of the _query-set_
27
+ # command.
28
+ def self.command_line_arguments
29
+ 'name value'
30
+ end
31
+
32
+ # Returns the help text for the _query-set_ command.
33
+ def self.help
34
+ "Sets a query string parameter in the request's address"
35
+ end
36
+
37
+ # Returns the extended help text for the _query-set_ command.
38
+ def self.help_extended
39
+ 'Sets a query string parameter used for the request. Does not ' +
40
+ "communicate with the endpoint.\n" +
41
+ "\n" +
42
+ 'The console prompt shows the address for the current request.'
43
+ end
44
+
45
+ # Returns related command classes for the _query-set_ command.
46
+ def self.see_also_commands
47
+ [HTTY::CLI::Commands::QueryUnset,
48
+ HTTY::CLI::Commands::QueryUnsetAll,
49
+ HTTY::CLI::Commands::Address]
50
+ end
51
+
52
+ # Performs the _query-set_ command.
53
+ def perform
54
+ add_request_if_has_response do |request|
55
+ request.query_set(*escape_or_warn_of_escape_sequences(arguments))
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,56 @@
1
+ # Defines HTTY::CLI::Commands::QueryUnset.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/address")
5
+ require File.expand_path("#{File.dirname __FILE__}/query_set")
6
+ require File.expand_path("#{File.dirname __FILE__}/query_unset_all")
7
+
8
+ module HTTY; end
9
+
10
+ class HTTY::CLI; end
11
+
12
+ module HTTY::CLI::Commands; end
13
+
14
+ # Encapsulates the _query-unset_ command.
15
+ class HTTY::CLI::Commands::QueryUnset < HTTY::CLI::Command
16
+
17
+ # Returns the name of a category under which help for the _query-unset_
18
+ # command should appear.
19
+ def self.category
20
+ 'Navigation'
21
+ end
22
+
23
+ # Returns the arguments for the command-line usage of the _query-unset_
24
+ # command.
25
+ def self.command_line_arguments
26
+ 'name'
27
+ end
28
+
29
+ # Returns the help text for the _query-unset_ command.
30
+ def self.help
31
+ "Removes a query string parameter from the request's address"
32
+ end
33
+
34
+ # Returns the extended help text for the _query-unset_ command.
35
+ def self.help_extended
36
+ 'Removes a query string parameter used for the request. Does not ' +
37
+ "communicate with the endpoint.\n" +
38
+ "\n" +
39
+ 'The console prompt shows the address for the current request.'
40
+ end
41
+
42
+ # Returns related command classes for the _query-unset_ command.
43
+ def self.see_also_commands
44
+ [HTTY::CLI::Commands::QuerySet,
45
+ HTTY::CLI::Commands::QueryUnsetAll,
46
+ HTTY::CLI::Commands::Address]
47
+ end
48
+
49
+ # Performs the _query-unset_ command.
50
+ def perform
51
+ add_request_if_has_response do |request|
52
+ request.query_unset(*arguments)
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,50 @@
1
+ # Defines HTTY::CLI::Commands::QueryUnsetAll.
2
+
3
+ require File.expand_path("#{File.dirname __FILE__}/../command")
4
+ require File.expand_path("#{File.dirname __FILE__}/address")
5
+ require File.expand_path("#{File.dirname __FILE__}/query_set")
6
+ require File.expand_path("#{File.dirname __FILE__}/query_unset")
7
+
8
+ module HTTY; end
9
+
10
+ class HTTY::CLI; end
11
+
12
+ module HTTY::CLI::Commands; end
13
+
14
+ # Encapsulates the _query-unset-all_ command.
15
+ class HTTY::CLI::Commands::QueryUnsetAll < HTTY::CLI::Command
16
+
17
+ # Returns the name of a category under which help for the _query-unset-all_
18
+ # command should appear.
19
+ def self.category
20
+ 'Navigation'
21
+ end
22
+
23
+ # Returns the help text for the _query-unset-all_ command.
24
+ def self.help
25
+ "Clears the query string of the request's address"
26
+ end
27
+
28
+ # Returns the extended help text for the _query-unset-all_ command.
29
+ def self.help_extended
30
+ 'Clears the query string used for the request. Does not communicate with ' +
31
+ "the endpoint.\n" +
32
+ "\n" +
33
+ 'The console prompt shows the address for the current request.'
34
+ end
35
+
36
+ # Returns related command classes for the _query-unset-all_ command.
37
+ def self.see_also_commands
38
+ [HTTY::CLI::Commands::QueryUnset,
39
+ HTTY::CLI::Commands::QuerySet,
40
+ HTTY::CLI::Commands::Address]
41
+ end
42
+
43
+ # Performs the _query-unset-all_ command.
44
+ def perform
45
+ add_request_if_has_response do |request|
46
+ request.query_unset_all(*arguments)
47
+ end
48
+ end
49
+
50
+ end