Overview
Comment: | utils/ofhttp: Add verbose mode |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
33760dee1a885b272318414190ef5aad |
User & Date: | js on 2015-05-24 10:58:21 |
Other Links: | manifest | tags |
Context
2015-05-24
| ||
16:19 | OFHTTPClient: Better checking for invalid reply check-in: 692fe63730 user: js tags: trunk | |
10:58 | utils/ofhttp: Add verbose mode check-in: 33760dee1a user: js tags: trunk | |
2015-05-23
| ||
11:21 | OFHTTPRequest: Rename entity to body check-in: c8877fd278 user: js tags: trunk | |
Changes
Modified utils/ofhttp/OFHTTP.m from [84d9105a37] to [de242f4469].
︙ | ︙ | |||
50 51 52 53 54 55 56 | @interface OFHTTP: OFObject { OFArray *_URLs; size_t _URLIndex; int _errorCode; OFString *_outputPath; | | | | > | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | @interface OFHTTP: OFObject { OFArray *_URLs; size_t _URLIndex; int _errorCode; OFString *_outputPath; bool _continue, _detectFileName, _quiet, _verbose; OFDataArray *_body; of_http_request_method_t _method; OFMutableDictionary *_clientHeaders; OFHTTPClient *_HTTPClient; char *_buffer; OFStream *_output; intmax_t _received, _length, _resumedFrom; ProgressBar *_progressBar; } @end OF_APPLICATION_DELEGATE(OFHTTP) static void help(OFStream *stream, bool full, int status) { [of_stderr writeFormat: @"Usage: %@ -[cehHmoOPqv] url1 [url2 ...]\n", [OFApplication programName]]; if (full) [stream writeString: @"\nOptions:\n" @" -b Specify the file to send as body\n" @" -c Continue download of existing file\n" @" -h Show this help\n" @" -H Add a header (e.g. X-Foo:Bar)\n" @" -m Set the method of the HTTP request\n" @" -o Specify output file name\n" @" -O Do a HEAD request to detect file name\n" @" -P Specify SOCKS5 proxy\n" @" -q Quiet mode (no output, except errors)\n" @" -v Verbose mode (print headers)\n"]; [OFApplication terminateWithStatus: status]; } @implementation OFHTTP - init { |
︙ | ︙ | |||
200 201 202 203 204 205 206 | [OFApplication terminateWithStatus: 1]; } } - (void)applicationDidFinishLaunching { OFOptionsParser *optionsParser = | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | [OFApplication terminateWithStatus: 1]; } } - (void)applicationDidFinishLaunching { OFOptionsParser *optionsParser = [OFOptionsParser parserWithOptions: @"bc:hH:m:o:OP:qv"]; of_unichar_t option; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case 'b': [self setBody: [optionsParser argument]]; break; |
︙ | ︙ | |||
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | break; case 'P': [self setProxy: [optionsParser argument]]; break; case 'q': _quiet = true; break; case ':': [of_stderr writeFormat: @"%@: Argument for option -%C " @"missing\n", [OFApplication programName], [optionsParser lastOption]]; [OFApplication terminateWithStatus: 1]; default: [of_stderr writeFormat: @"%@: Unknown option: -%C\n", [OFApplication programName], [optionsParser lastOption]]; [OFApplication terminateWithStatus: 1]; } } _URLs = [[optionsParser remainingArguments] retain]; if ([_URLs count] < 1) help(of_stderr, false, 1); if (_outputPath != nil && [_URLs count] > 1) { [of_stderr writeFormat: @"%@: Cannot use -o when more than " @"one URL has been specified!\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } | > > > > > > > > > > | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | break; case 'P': [self setProxy: [optionsParser argument]]; break; case 'q': _quiet = true; break; case 'v': _verbose = true; break; case ':': [of_stderr writeFormat: @"%@: Argument for option -%C " @"missing\n", [OFApplication programName], [optionsParser lastOption]]; [OFApplication terminateWithStatus: 1]; default: [of_stderr writeFormat: @"%@: Unknown option: -%C\n", [OFApplication programName], [optionsParser lastOption]]; [OFApplication terminateWithStatus: 1]; } } _URLs = [[optionsParser remainingArguments] retain]; if ([_URLs count] < 1) help(of_stderr, false, 1); if (_quiet && _verbose) { [of_stderr writeFormat: @"%@: -q and -v are mutually " @"exclusive!\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } if (_outputPath != nil && [_URLs count] > 1) { [of_stderr writeFormat: @"%@: Cannot use -o when more than " @"one URL has been specified!\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } |
︙ | ︙ | |||
646 647 648 649 650 651 652 | else lengthString = [OFString stringWithFormat: @"%jd bytes", _resumedFrom + _length]; } else lengthString = @"unknown"; [of_stdout writeFormat: @" Name: %@\n", fileName]; | > > > > > > > > > > > > > > > > | | > | 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 | else lengthString = [OFString stringWithFormat: @"%jd bytes", _resumedFrom + _length]; } else lengthString = @"unknown"; [of_stdout writeFormat: @" Name: %@\n", fileName]; if (_verbose) { void *pool = objc_autoreleasePoolPush(); OFDictionary *headers = [response headers]; OFEnumerator *keyEnumerator = [headers keyEnumerator]; OFEnumerator *objectEnumerator = [headers objectEnumerator]; OFString *key, *object; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) [of_stdout writeFormat: @" %@: %@\n", key, object]; objc_autoreleasePoolPop(pool); } else { [of_stdout writeFormat: @" Type: %@\n", type]; [of_stdout writeFormat: @" Size: %@\n", lengthString]; } } if ([_outputPath isEqual: @"-"]) _output = of_stdout; else { if (!_continue && [OFFile fileExistsAtPath: fileName]) { [of_stderr writeFormat: |
︙ | ︙ |