@@ -26,7 +26,7 @@ def parse_args(args)
26
26
'-3' => [ false , 'Use SSLv3 (SSL)' ] ,
27
27
'-A' => [ true , 'User-Agent to send to server' ] ,
28
28
'-d' => [ true , 'HTTP POST data' ] ,
29
- '-G' => [ false , 'Send the -d data with a HTTP GET' ] ,
29
+ '-G' => [ false , 'Send the -d data with an HTTP GET' ] ,
30
30
'-h' => [ false , 'This help text' ] ,
31
31
'-H' => [ true , 'Custom header to pass to server' ] ,
32
32
'-i' => [ false , 'Include headers in the output' ] ,
@@ -81,7 +81,7 @@ def parse_args(args)
81
81
options [ :print_body ] = false
82
82
options [ :method ] ||= 'HEAD'
83
83
when '-o'
84
- options [ :output_file ] = val
84
+ options [ :output_file ] = File . expand_path ( val )
85
85
when '-u'
86
86
val = val . partition ( ':' )
87
87
options [ :auth_username ] = val [ 0 ]
@@ -174,22 +174,28 @@ def cmd_http_request(*args)
174
174
ensure
175
175
http_client . close
176
176
end
177
- return unless response
177
+
178
+ unless response
179
+ opts [ :output_file ] . close unless opts [ :output_file ] . nil?
180
+ return
181
+ end
178
182
179
183
if opts [ :print_headers ]
180
184
output_line ( opts , response . cmd_string )
181
185
output_line ( opts , response . headers . to_s )
182
186
end
183
187
184
188
output_line ( opts , response . body ) if opts [ :print_body ]
185
- opts [ :output_file ] . close unless opts [ :output_file ] . nil?
189
+ unless opts [ :output_file ] . nil?
190
+ print_status ( "Wrote #{ opts [ :output_file ] . tell } bytes to #{ opts [ :output_file ] . path } " )
191
+ opts [ :output_file ] . close
192
+ end
186
193
end
187
194
end
188
195
189
196
def initialize ( framework , opts )
190
197
super
191
198
add_console_dispatcher ( ConsoleCommandDispatcher )
192
- print_status ( "#{ name } plugin loaded." )
193
199
end
194
200
195
201
def cleanup
0 commit comments