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,13 +1,10 @@
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/session")
2
+ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/request")
3
+ require File.expand_path("#{File.dirname __FILE__}/../../../lib/htty/session")
4
4
 
5
5
  describe HTTY::Session do
6
- before :each do
7
- @session = HTTY::Session.new('foo')
8
- end
9
-
10
6
  it 'should have one request with the expected URI' do
11
- @session.requests.should == [HTTY::Request.new('foo')]
7
+ session = HTTY::Session.new('foo')
8
+ session.requests.should == [HTTY::Request.new('foo')]
12
9
  end
13
10
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
+ - 1
7
8
  - 0
8
- - 0
9
- version: 1.0.0
9
+ version: 1.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nils Jonsson
@@ -14,103 +14,161 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-06 00:00:00 -05:00
17
+ date: 2010-09-28 00:00:00 -05:00
18
18
  default_executable:
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: bluecloth
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 0
31
+ - 7
32
+ version: 2.0.7
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: yard
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ - 6
46
+ - 1
47
+ version: 0.6.1
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rake
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ - 8
61
+ - 7
62
+ version: 0.8.7
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rspec
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 1
75
+ - 3
76
+ - 0
77
+ version: 1.3.0
78
+ type: :development
79
+ version_requirements: *id004
21
80
  description: htty is a console application for interacting with HTTP servers. It is something of a cross between curl and the Lynx browser.
22
81
  email: htty@nilsjonsson.com
23
82
  executables:
24
83
  - htty
25
84
  extensions: []
26
85
 
27
- extra_rdoc_files:
28
- - README.rdoc
29
- - MIT-LICENSE.rdoc
86
+ extra_rdoc_files: []
87
+
30
88
  files:
31
- - README.rdoc
32
- - MIT-LICENSE.rdoc
89
+ - README.markdown
90
+ - History.markdown
91
+ - MIT-LICENSE.markdown
33
92
  - VERSION
34
- - app/htty/cli/command.rb
35
- - app/htty/cli/commands/address.rb
36
- - app/htty/cli/commands/body_clear.rb
37
- - app/htty/cli/commands/body_request.rb
38
- - app/htty/cli/commands/body_response.rb
39
- - app/htty/cli/commands/body_set.rb
40
- - app/htty/cli/commands/body_unset.rb
41
- - app/htty/cli/commands/cd.rb
42
- - app/htty/cli/commands/cookie_add.rb
43
- - app/htty/cli/commands/cookie_remove.rb
44
- - app/htty/cli/commands/cookies.rb
45
- - app/htty/cli/commands/cookies_add.rb
46
- - app/htty/cli/commands/cookies_clear.rb
47
- - app/htty/cli/commands/cookies_remove.rb
48
- - app/htty/cli/commands/cookies_remove_all.rb
49
- - app/htty/cli/commands/cookies_use.rb
50
- - app/htty/cli/commands/delete.rb
51
- - app/htty/cli/commands/exit.rb
52
- - app/htty/cli/commands/follow.rb
53
- - app/htty/cli/commands/form.rb
54
- - app/htty/cli/commands/form_add.rb
55
- - app/htty/cli/commands/form_clear.rb
56
- - app/htty/cli/commands/form_remove.rb
57
- - app/htty/cli/commands/form_remove_all.rb
58
- - app/htty/cli/commands/fragment_clear.rb
59
- - app/htty/cli/commands/fragment_set.rb
60
- - app/htty/cli/commands/fragment_unset.rb
61
- - app/htty/cli/commands/get.rb
62
- - app/htty/cli/commands/header_set.rb
63
- - app/htty/cli/commands/header_unset.rb
64
- - app/htty/cli/commands/headers_clear.rb
65
- - app/htty/cli/commands/headers_request.rb
66
- - app/htty/cli/commands/headers_response.rb
67
- - app/htty/cli/commands/headers_set.rb
68
- - app/htty/cli/commands/headers_unset.rb
69
- - app/htty/cli/commands/headers_unset_all.rb
70
- - app/htty/cli/commands/help.rb
71
- - app/htty/cli/commands/history.rb
72
- - app/htty/cli/commands/history_verbose.rb
73
- - app/htty/cli/commands/host_set.rb
74
- - app/htty/cli/commands/http_delete.rb
75
- - app/htty/cli/commands/http_get.rb
76
- - app/htty/cli/commands/http_head.rb
77
- - app/htty/cli/commands/http_options.rb
78
- - app/htty/cli/commands/http_post.rb
79
- - app/htty/cli/commands/http_put.rb
80
- - app/htty/cli/commands/http_trace.rb
81
- - app/htty/cli/commands/path_set.rb
82
- - app/htty/cli/commands/port_set.rb
83
- - app/htty/cli/commands/post.rb
84
- - app/htty/cli/commands/put.rb
85
- - app/htty/cli/commands/query_clear.rb
86
- - app/htty/cli/commands/query_set.rb
87
- - app/htty/cli/commands/query_unset.rb
88
- - app/htty/cli/commands/query_unset_all.rb
89
- - app/htty/cli/commands/quit.rb
90
- - app/htty/cli/commands/reuse.rb
91
- - app/htty/cli/commands/scheme_set.rb
92
- - app/htty/cli/commands/status.rb
93
- - app/htty/cli/commands/undo.rb
94
- - app/htty/cli/commands/userinfo_clear.rb
95
- - app/htty/cli/commands/userinfo_set.rb
96
- - app/htty/cli/commands/userinfo_unset.rb
97
- - app/htty/cli/commands.rb
98
- - app/htty/cli/cookie_clearing_command.rb
99
- - app/htty/cli/display.rb
100
- - app/htty/cli/http_method_command.rb
101
- - app/htty/cli/url_escaping.rb
102
- - app/htty/cli.rb
103
- - app/htty/cookies_util.rb
104
- - app/htty/no_location_header_error.rb
105
- - app/htty/no_response_error.rb
106
- - app/htty/no_set_cookie_header_error.rb
107
- - app/htty/ordered_hash.rb
108
- - app/htty/payload.rb
109
- - app/htty/request.rb
110
- - app/htty/requests_util.rb
111
- - app/htty/response.rb
112
- - app/htty/session.rb
113
- - app/htty.rb
93
+ - lib/htty/cli/command.rb
94
+ - lib/htty/cli/commands/address.rb
95
+ - lib/htty/cli/commands/body_clear.rb
96
+ - lib/htty/cli/commands/body_request.rb
97
+ - lib/htty/cli/commands/body_response.rb
98
+ - lib/htty/cli/commands/body_set.rb
99
+ - lib/htty/cli/commands/body_unset.rb
100
+ - lib/htty/cli/commands/cd.rb
101
+ - lib/htty/cli/commands/cookie_add.rb
102
+ - lib/htty/cli/commands/cookie_remove.rb
103
+ - lib/htty/cli/commands/cookies.rb
104
+ - lib/htty/cli/commands/cookies_add.rb
105
+ - lib/htty/cli/commands/cookies_clear.rb
106
+ - lib/htty/cli/commands/cookies_remove.rb
107
+ - lib/htty/cli/commands/cookies_remove_all.rb
108
+ - lib/htty/cli/commands/cookies_use.rb
109
+ - lib/htty/cli/commands/delete.rb
110
+ - lib/htty/cli/commands/exit.rb
111
+ - lib/htty/cli/commands/follow.rb
112
+ - lib/htty/cli/commands/form.rb
113
+ - lib/htty/cli/commands/form_add.rb
114
+ - lib/htty/cli/commands/form_clear.rb
115
+ - lib/htty/cli/commands/form_remove.rb
116
+ - lib/htty/cli/commands/form_remove_all.rb
117
+ - lib/htty/cli/commands/fragment_clear.rb
118
+ - lib/htty/cli/commands/fragment_set.rb
119
+ - lib/htty/cli/commands/fragment_unset.rb
120
+ - lib/htty/cli/commands/get.rb
121
+ - lib/htty/cli/commands/header_set.rb
122
+ - lib/htty/cli/commands/header_unset.rb
123
+ - lib/htty/cli/commands/headers_clear.rb
124
+ - lib/htty/cli/commands/headers_request.rb
125
+ - lib/htty/cli/commands/headers_response.rb
126
+ - lib/htty/cli/commands/headers_set.rb
127
+ - lib/htty/cli/commands/headers_unset.rb
128
+ - lib/htty/cli/commands/headers_unset_all.rb
129
+ - lib/htty/cli/commands/help.rb
130
+ - lib/htty/cli/commands/history.rb
131
+ - lib/htty/cli/commands/history_verbose.rb
132
+ - lib/htty/cli/commands/host_set.rb
133
+ - lib/htty/cli/commands/http_delete.rb
134
+ - lib/htty/cli/commands/http_get.rb
135
+ - lib/htty/cli/commands/http_head.rb
136
+ - lib/htty/cli/commands/http_options.rb
137
+ - lib/htty/cli/commands/http_post.rb
138
+ - lib/htty/cli/commands/http_put.rb
139
+ - lib/htty/cli/commands/http_trace.rb
140
+ - lib/htty/cli/commands/path_set.rb
141
+ - lib/htty/cli/commands/port_set.rb
142
+ - lib/htty/cli/commands/post.rb
143
+ - lib/htty/cli/commands/put.rb
144
+ - lib/htty/cli/commands/query_clear.rb
145
+ - lib/htty/cli/commands/query_set.rb
146
+ - lib/htty/cli/commands/query_unset.rb
147
+ - lib/htty/cli/commands/query_unset_all.rb
148
+ - lib/htty/cli/commands/quit.rb
149
+ - lib/htty/cli/commands/reuse.rb
150
+ - lib/htty/cli/commands/scheme_set.rb
151
+ - lib/htty/cli/commands/status.rb
152
+ - lib/htty/cli/commands/undo.rb
153
+ - lib/htty/cli/commands/userinfo_clear.rb
154
+ - lib/htty/cli/commands/userinfo_set.rb
155
+ - lib/htty/cli/commands/userinfo_unset.rb
156
+ - lib/htty/cli/commands.rb
157
+ - lib/htty/cli/display.rb
158
+ - lib/htty/cli/http_method_command.rb
159
+ - lib/htty/cli/url_escaping.rb
160
+ - lib/htty/cli.rb
161
+ - lib/htty/cookies_util.rb
162
+ - lib/htty/no_location_header_error.rb
163
+ - lib/htty/no_response_error.rb
164
+ - lib/htty/no_set_cookie_header_error.rb
165
+ - lib/htty/ordered_hash.rb
166
+ - lib/htty/payload.rb
167
+ - lib/htty/request.rb
168
+ - lib/htty/requests_util.rb
169
+ - lib/htty/response.rb
170
+ - lib/htty/session.rb
171
+ - lib/htty.rb
114
172
  - spec/unit/htty/cli_spec.rb
115
173
  - spec/unit/htty/ordered_hash_spec.rb
116
174
  - spec/unit/htty/request_spec.rb
@@ -122,13 +180,8 @@ homepage: http://htty.github.com
122
180
  licenses: []
123
181
 
124
182
  post_install_message:
125
- rdoc_options:
126
- - --title
127
- - htty, the HTTP TTY
128
- - --main
129
- - README.rdoc
130
- - --output
131
- - doc
183
+ rdoc_options: []
184
+
132
185
  require_paths:
133
186
  - lib
134
187
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -148,8 +201,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
201
  - 0
149
202
  version: "0"
150
203
  requirements:
151
- - Ruby v1.9.2 or later
152
- rubyforge_project:
204
+ - Ruby v1.8.7 or later
205
+ rubyforge_project: htty
153
206
  rubygems_version: 1.3.7
154
207
  signing_key:
155
208
  specification_version: 3
@@ -1,9 +0,0 @@
1
- The MIT License
2
-
3
- Source code for _htty_ is copyright (c) 2010 Nils Jonsson[mailto:htty@nilsjonsson.com].
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,199 +0,0 @@
1
- __ .__
2
- s s _/ |_| |__ ____
3
- .uef^" :8 :8 .. \ __\ | \_/ __ \
4
- :d88E .88 .88 @L | | | Y \ ___/
5
- `888E :888ooo :888ooo 9888i .dL |__| |___| /\___ >
6
- 888E .z8k -*8888888 -*8888888 `Y888k:*888. __________\/_____\/____________________
7
- 888E~?888L 8888 8888 888E 888I / | \__ ___/\__ ___/\______ \
8
- 888E 888E 8888 8888 888E 888I / ~ \| | | | | ___/
9
- 888E 888E 8888 8888 888E 888I \ Y /| | | | | |
10
- 888E 888E .8888Lu= .8888Lu= 888E 888I \___|_ / |____| |____| |____|
11
- 888E 888E ^%888* ^%888* x888N><888' ______\/___________________.___.
12
- m888N= 888> 'Y" 'Y" "88" 888 \__ ___/\__ ___/\__ | |
13
- `Y" 888 88F | | | | / | |
14
- J88" 98" | | | | \____ |
15
- @% ./" |____| |____| / ______|
16
- :" ~` \/
17
-
18
-
19
- htty[http://htty.github.com] is a console application for interacting with HTTP servers. It's something of a cross between _curl_ and the Lynx browser.
20
-
21
- = Installation
22
-
23
- It couldn't be much easier.
24
-
25
- $ gem install htty
26
-
27
- You'll need Ruby and RubyGems. It's known to work well under OS X against Ruby v1.8.7 and v1.9.2 under OS X.
28
-
29
- = Features
30
-
31
- * Intuitive commands and command aliases
32
- * Support for familiar HTTP methods _GET_, _POST_, _PUT_, and _DELETE_, as well as _HEAD_, _OPTIONS_ and _TRACE_
33
- * Automatic URL-encoding of query-string parameters and URL fragments
34
- * Transcripts, both verbose and summary
35
- * Dead-simple cookie handling and redirect following
36
- * Built-in help
37
-
38
- The things you can do with _htty_ are:
39
-
40
- * <b>Build a request</b> -- you can tweak the address, headers, cookies, and body at will
41
- * <b>Send the request to the server</b> -- after the request is sent, it remains unchanged in your session history
42
- * <b>Inspect the server's response</b> -- you can look at the status, headers, cookies, and body in various ways
43
- * <b>Review history</b> -- a normal and a verbose transcript of your session are available at all times (destroyed when you quit _htty_)
44
- * <b>Reuse previous requests</b> -- you can refer to prior requests and copy them
45
-
46
- = Examples
47
-
48
- Here are a few annotated _htty_ session transcripts to get you started.
49
-
50
- == Querying a web service
51
-
52
- This simple example shows how to explore read-only web services with _htty_.
53
-
54
- link:../doc_bin/esvapi1.png
55
-
56
- You can point _htty_ at a complete or partial web URL. If you don't supply a URL, \http://0.0.0.0/ (port 80) will be used. You can vary the protocol scheme, userinfo, host, port, path, query string, and fragment as you wish.
57
-
58
- The _htty_ shell prompt shows the address of the current request.
59
-
60
- The +get+ command is one of seven HTTP request methods supported. A concise summary of the response is shown when you issue a request.
61
-
62
- You can follow redirects using the +follow+ command.
63
-
64
- link:../doc_bin/esvapi2.png
65
-
66
- You can tweak segments of the address at will. Here we are navigating the site's path hierarchy, which you can do with relative as well as absolute pathspecs.
67
-
68
- link:../doc_bin/esvapi3.png
69
-
70
- Here we add query-string parameters. Notice that characters that require URL encoding are automatically URL-encoded (unless they are part of a URL-encoded expression).
71
-
72
- The +headers-response+ and +body-response+ commands reveal the details of a response.
73
-
74
- link:../doc_bin/esvapi4.png
75
-
76
- There was some cruft in the web service's response (a horizontal line, a passage reference, verse numbers, a copyright stamp, and line breaks). We eliminate it by using API options provided by the web service we're talking to.
77
-
78
- We do a Julia Child maneuver and use the +address+ command to change the entire URL, rather than add individual query-string parameters one by one.
79
-
80
- Exit your session at any time by typing +quit+.
81
-
82
- == Working with cookies
83
-
84
- The next example demonstrates _htty_'s cookies features, as well as how to review and revisit past requests.
85
-
86
- link:../doc_bin/google1.png
87
-
88
- Notice that when cookies are offered in a response, a bold asterisk (it looks like a cookie) appears in the response summary. The same cookie symbol appears next to the _Set-Cookie_ header when you display response headers.
89
-
90
- link:../doc_bin/google2.png
91
-
92
- The +cookies-use+ command copies cookies out of the response into the next request. The cookie symbol appears next to the _Cookie_ header when you display request headers.
93
-
94
- link:../doc_bin/google3.png
95
-
96
- An abbreviated history is available through the +history+ command. Information about requests in the history includes request method, URL, number of headers (and a cookie symbol, if cookies were sent), and the size of the body. Information about responses in the history includes response code, number of headers (and a cookie symbol, if cookies were received), and the size of the body.
97
-
98
- Note that history contains only numbered HTTP request and response pairs, not a record of all the commands you enter.
99
-
100
- The +reuse+ command makes a copy of the headers and body of an earlier request for you to build on.
101
-
102
- == Understanding complex HTTP conversations at a glance using history
103
-
104
- Assume that we have the following Sinatra application listening on Sinatra's default port, 4567.
105
-
106
- require 'sinatra'
107
-
108
- get '/all-good' do
109
- [200, [['Set-Cookie', 'foo=bar; baz']], 'Hello World!']
110
- end
111
-
112
- get '/huh' do
113
- [404, 'What?']
114
- end
115
-
116
- get '/hurl' do
117
- [500, 'Barf!']
118
- end
119
-
120
- post '/give-it-to-me' do
121
- redirect '/all-good'
122
- end
123
-
124
- This application expects _GET_ and _POST_ requests and responds in various contrived ways.
125
-
126
- link:../doc_bin/sinatra1.png
127
-
128
- Here you can see a request body being specified. Type +body-set+ to enter body data, and terminate it by typing Return three times consecutively.
129
-
130
- Also note how different response codes are rendered:
131
-
132
- * Response codes between 200 and 299 appear black on green to indicate success
133
- * Response codes between 300 and 399 appear white on blue to indicate redirection
134
- * Response codes between 400 and 499 appear white on red to indicate failure
135
- * Response codes between 500 and 599 appear flashing black on yellow to indicate a server error
136
-
137
- link:../doc_bin/sinatra2.png
138
-
139
- As with the abbreviated history demonstrated earlier, verbose history shows a numbered list of requests and the responses they elicited. All information exchanged between client and server is shown.
140
-
141
- == Getting help
142
-
143
- You can learn how to use _htty_ commands from within _htty_.
144
-
145
- link:../doc_bin/help.png
146
-
147
- The +help+ command takes an optional argument of the abbreviated or full name of a command.
148
-
149
- = Coming soon
150
-
151
- Here are some features that are coming down the pike.
152
-
153
- == HTTP Secure URLs
154
-
155
- The HTTPS code is broken right now. Pardon the dust.
156
-
157
- == Commands for streamlining web form submission
158
-
159
- These features will make _htty_ better at screen-scraping.
160
-
161
- Using any of the forthcoming +form+ commands will clear any non-form content in the body of the request. Adding at least one URL-encoded form parameter to the request will set the _Content-Type_ header to _application/x-www-form-urlencoded_. Removing all URL-encoded form parameters will remove this header.
162
-
163
- * +form+ -- display all form parameters offered in the response
164
- * +form-fill+ -- prompt in turn for a value for each of the form inputs in the response
165
- * <tt>form-add _name_ _value_</tt> -- add a URL-encoded form parameter for the request, using the specified name and value
166
- * <tt>form-remove _name_</tt> -- remove a URL-encoded form parameter from the request, using the specified name
167
- * +form-remove-all+ -- remove all URL-encoded form parameters from the request
168
-
169
- You will also be able to pop open a browser window containing request and response bodies.
170
-
171
- == Shiny _curses_ goodness
172
-
173
- We'll have command history using the arrow keys, command autocompletion, and Tab key navigation of forms.
174
-
175
- == Custom command aliases and shell emulation of _http-console_
176
-
177
- You should be able to make your own command aliases.
178
-
179
- _http-console_ has a nice command-line. We should have an _http-console_ skin for _htty_.
180
-
181
- = Contributing
182
-
183
- Your patches are welcome, and you will receive attribution here for good stuff.
184
-
185
- Fork the official _htty_ repository located at http://github.com/htty/htty and send a pull request to htty[http://github.com/htty].
186
-
187
- = News and information
188
-
189
- Stay in touch with the _htty_ project by following the Twitter account: get_htty[http://twitter.com/get_htty].
190
-
191
- You can also get help in the \#htty channel on Freenode[http://webchat.freenode.net/?channels=htty].
192
-
193
- = Credits
194
-
195
- The author, Nils&nbsp;Jonsson[mailto:htty@nilsjonsson.com], owes a debt of inspiration to the http-console[http://github.com/cloudhead/http-console] project.
196
-
197
- = License
198
-
199
- Released under the MIT&nbsp;License[link:MIT-LICENSE_rdoc.html].