Differences From Artifact [8b8198d6dd]:
- File
src/OFHTTPClient.m
— part of check-in
[efe7be259d]
at
2013-02-18 21:53:56
on branch trunk
— Rename -[OFStream pendingBytes].
It is now called -[numberOfBytesInReadBuffer].
Additionally, this commit renames OFStream's _cache to _readBuffer. (user: js, size: 10970) [annotate] [blame] [check-ins using]
To Artifact [4a71698195]:
- File
src/OFHTTPClient.m
— part of check-in
[c5ef582958]
at
2013-03-04 17:20:15
on branch trunk
— Replace BOOL with bool.
The only places where BOOL is left are those where they are required by
the ABI. (user: js, size: 10982) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
41 42 43 44 45 46 47 | #import "autorelease.h" #import "macros.h" static OF_INLINE void normalize_key(char *str_) { uint8_t *str = (uint8_t*)str_; | | | | | | 41 42 43 44 45 46 47 48 49 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 | #import "autorelease.h" #import "macros.h" static OF_INLINE void normalize_key(char *str_) { uint8_t *str = (uint8_t*)str_; bool firstLetter = true; while (*str != '\0') { if (!isalnum(*str)) { firstLetter = true; str++; continue; } *str = (firstLetter ? toupper(*str) : tolower(*str)); firstLetter = false; str++; } } @interface OFHTTPClientReply: OFHTTPRequestReply { OFTCPSocket *_socket; bool _chunked, _atEndOfStream; size_t _toRead; } - initWithSocket: (OFTCPSocket*)socket; @end @implementation OFHTTPClientReply |
︙ | ︙ | |||
141 142 143 144 145 146 147 | } @catch (OFInvalidFormatException *e) { @throw [OFInvalidServerReplyException exceptionWithClass: [self class]]; } if (_toRead == 0) { [_socket close]; | | | | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | } @catch (OFInvalidFormatException *e) { @throw [OFInvalidServerReplyException exceptionWithClass: [self class]]; } if (_toRead == 0) { [_socket close]; _atEndOfStream = true; } objc_autoreleasePoolPop(pool); return 0; } } - (bool)lowlevelIsAtEndOfStream { if (!_chunked) return [_socket isAtEndOfStream]; return _atEndOfStream; } |
︙ | ︙ | |||
191 192 193 194 195 196 197 | } - (id <OFHTTPClientDelegate>)delegate { return _delegate; } | | | | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | } - (id <OFHTTPClientDelegate>)delegate { return _delegate; } - (void)setInsecureRedirectsAllowed: (bool)allowed { _insecureRedirectsAllowed = allowed; } - (bool)insecureRedirectsAllowed { return _insecureRedirectsAllowed; } - (OFHTTPRequestReply*)performRequest: (OFHTTPRequest*)request { return [self performRequest: request |
︙ | ︙ | |||
254 255 256 257 258 259 260 | [socket connectToHost: [URL host] port: [URL port]]; /* * Work around a bug with packet splitting in lighttpd when using * HTTPS. */ | | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | [socket connectToHost: [URL host] port: [URL port]]; /* * Work around a bug with packet splitting in lighttpd when using * HTTPS. */ [socket setWriteBufferEnabled: true]; if (requestType == OF_HTTP_REQUEST_TYPE_GET) type = "GET"; if (requestType == OF_HTTP_REQUEST_TYPE_HEAD) type = "HEAD"; if (requestType == OF_HTTP_REQUEST_TYPE_POST) type = "POST"; |
︙ | ︙ | |||
308 309 310 311 312 313 314 | [POSTData count] * [POSTData itemSize]]; } [socket writeString: @"\r\n"]; /* Work around a bug in lighttpd, see above */ [socket flushWriteBuffer]; | | | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | [POSTData count] * [POSTData itemSize]]; } [socket writeString: @"\r\n"]; /* Work around a bug in lighttpd, see above */ [socket flushWriteBuffer]; [socket setWriteBufferEnabled: false]; if (requestType == OF_HTTP_REQUEST_TYPE_POST) [socket writeBuffer: [POSTData items] length: [POSTData count] * [POSTData itemSize]]; @try { line = [socket readLine]; |
︙ | ︙ | |||
371 372 373 374 375 376 377 | memcpy(keyC, lineC, tmp - lineC); keyC[tmp - lineC] = '\0'; normalize_key(keyC); @try { key = [OFString stringWithUTF8StringNoCopy: keyC | | | | 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | memcpy(keyC, lineC, tmp - lineC); keyC[tmp - lineC] = '\0'; normalize_key(keyC); @try { key = [OFString stringWithUTF8StringNoCopy: keyC freeWhenDone: true]; } @catch (id e) { free(keyC); @throw e; } do { tmp++; } while (*tmp == ' '); value = [OFString stringWithUTF8String: tmp]; if ((redirects > 0 && (status == 301 || status == 302 || status == 303 || status == 307) && [key isEqual: @"Location"]) && (_insecureRedirectsAllowed || [scheme isEqual: @"http"] || ![value hasPrefix: @"http://"])) { OFURL *newURL; OFHTTPRequest *newRequest; bool follow = true; newURL = [OFURL URLWithString: value relativeToURL: URL]; if ([_delegate respondsToSelector: @selector(client:shouldFollowRedirect:request:)]) follow = [_delegate client: self |
︙ | ︙ |