Differences From Artifact [f40132b96b]:
- File
utils/ofhttp/OFHTTP.m
— part of check-in
[486073790c]
at
2015-04-26 12:24:37
on branch trunk
— Add utils/ofhttp
This is a small tool to download files via HTTP(S). (user: js, size: 8135) [annotate] [blame] [check-ins using]
To Artifact [4922b58539]:
- File utils/ofhttp/OFHTTP.m — part of check-in [05a0a6f65c] at 2015-04-26 12:45:45 on branch trunk — utils/ofhttp: Print redirects in non-quiet mode (user: js, size: 8433) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
@implementation OFHTTP
- init
{
self = [super init];
@try {
_HTTPClient = [[OFHTTPClient alloc] init];
_buffer = [self allocMemoryWithSize: [OFSystemInfo pageSize]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
| > > | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
@implementation OFHTTP
- init
{
self = [super init];
@try {
_HTTPClient = [[OFHTTPClient alloc] init];
[_HTTPClient setDelegate: self];
_buffer = [self allocMemoryWithSize: [OFSystemInfo pageSize]];
} @catch (id e) {
[self release];
@throw e;
}
return self;
|
| ︙ | ︙ | |||
134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
[OFApplication programName]];
[OFApplication terminateWithStatus: 1];
}
[self performSelector: @selector(downloadNextURL)
afterDelay: 0];
}
- (bool)stream: (OFHTTPResponse*)response
didReadIntoBuffer: (void*)buffer
length: (size_t)length
exception: (OFException*)e
{
if (e != nil) {
| > > > > > > > > > > > > | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
[OFApplication programName]];
[OFApplication terminateWithStatus: 1];
}
[self performSelector: @selector(downloadNextURL)
afterDelay: 0];
}
- (bool)client: (OFHTTPClient*)client
shouldFollowRedirect: (OFURL*)URL
statusCode: (int)statusCode
request: (OFHTTPRequest*)request
{
if (!_quiet)
[of_stdout writeFormat: @" ➜ %d\n↻ %@",
statusCode, [URL string]];
return true;
}
- (bool)stream: (OFHTTPResponse*)response
didReadIntoBuffer: (void*)buffer
length: (size_t)length
exception: (OFException*)e
{
if (e != nil) {
|
| ︙ | ︙ |