Comment: | Make OFHTTPRequestReply a stream.
This also implements chunked transfer encoding for OFHTTPServer and adds Additionally, this makes it possible to add an async version of |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
bdf9c4d96b0c915d89deb2baeb55b544 |
User & Date: | js on 2013-01-26 00:13:56 |
Other Links: | manifest | tags |
2013-01-28
| ||
14:29 | TableGenerator: Process files on-the-fly. check-in: 4f8251772c user: js tags: trunk | |
2013-01-26
| ||
00:13 | Make OFHTTPRequestReply a stream. check-in: bdf9c4d96b user: js tags: trunk | |
2013-01-25
| ||
22:39 | Make -[OFStream setBlocking:] more robust. check-in: 436f274d65 user: js tags: trunk | |
Modified src/OFDataArray.m from [df33921628] to [993787fe25].
︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | + + | #import "OFDataArray.h" #import "OFString.h" #import "OFFile.h" #import "OFURL.h" #import "OFHTTPClient.h" #import "OFHTTPRequest.h" #import "OFHTTPRequestReply.h" #import "OFDictionary.h" #import "OFXMLElement.h" #import "OFSystemInfo.h" #import "OFHTTPRequestFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "autorelease.h" #import "base64.h" #import "macros.h" /* References for static linking */ void _references_to_categories_of_OFDataArray(void) |
︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | + + | - initWithContentsOfURL: (OFURL*)URL { void *pool; OFHTTPClient *client; OFHTTPRequest *request; OFHTTPRequestReply *reply; OFDictionary *headers; OFString *contentLength; Class c; c = [self class]; [self release]; pool = objc_autoreleasePoolPush(); |
︙ | |||
163 164 165 166 167 168 169 | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | - + + + + + + + + + | if ([reply statusCode] != 200) @throw [OFHTTPRequestFailedException exceptionWithClass: [request class] request: request reply: reply]; |
︙ |
Modified src/OFHTTPClient.h from [aa40337e14] to [19781d2abd].
︙ | |||
57 58 59 60 61 62 63 | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | - - - - - - - - - - - - - - - | * received */ - (void)client: (OFHTTPClient*)client didReceiveHeaders: (OFDictionary*)headers statusCode: (int)statusCode request: (OFHTTPRequest*)request; |
︙ | |||
101 102 103 104 105 106 107 | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | - - | /*! * @brief A class for performing HTTP requests. */ @interface OFHTTPClient: OFObject { id <OFHTTPClientDelegate> delegate; |
︙ | |||
146 147 148 149 150 151 152 | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | - - - - - - - - - - - - - - - - - | /*! * @brief Returns whether redirects from HTTPS to HTTP will be allowed * * @return Whether redirects from HTTPS to HTTP will be allowed */ - (BOOL)insecureRedirectsAllowed; |
︙ |
Modified src/OFHTTPClient.m from [07b706d2dd] to [9a386c8c54].
︙ | |||
23 24 25 26 27 28 29 | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | - | #import "OFHTTPRequest.h" #import "OFHTTPRequestReply.h" #import "OFString.h" #import "OFURL.h" #import "OFTCPSocket.h" #import "OFDictionary.h" #import "OFDataArray.h" |
︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + - - + - - - - - | *str = (firstLetter ? toupper(*str) : tolower(*str)); firstLetter = NO; str++; } } @interface OFHTTPClientReply: OFHTTPRequestReply { OFTCPSocket *sock; BOOL chunked, atEndOfStream; size_t toRead; } - initWithSocket: (OFTCPSocket*)sock; @end @implementation OFHTTPClientReply - initWithSocket: (OFTCPSocket*)sock_ { self = [super init]; sock = [sock_ retain]; return self; } - (void)dealloc { [sock release]; [super dealloc]; } - (void)setHeaders: (OFDictionary*)headers_ { [super setHeaders: headers_]; chunked = [[headers_ objectForKey: @"Transfer-Encoding"] isEqual: @"chunked"]; } - (size_t)lowlevelReadIntoBuffer: (void*)buffer length: (size_t)length { if (!chunked) return [sock readIntoBuffer: buffer length: length]; if (toRead > 0) { if (length > toRead) length = toRead; length = [sock readIntoBuffer: buffer length: length]; toRead -= length; if (toRead == 0) if ([[sock readLine] length] > 0) @throw [OFInvalidServerReplyException exceptionWithClass: [self class]]; return length; } else { void *pool = objc_autoreleasePoolPush(); OFString *line; of_range_t range; @try { line = [sock readLine]; } @catch (OFInvalidEncodingException *e) { @throw [OFInvalidServerReplyException exceptionWithClass: [self class]]; } range = [line rangeOfString: @";"]; if (range.location != OF_NOT_FOUND) line = [line substringWithRange: of_range(0, range.location)]; @try { toRead = (size_t)[line hexadecimalValue]; } @catch (OFInvalidFormatException *e) { @throw [OFInvalidServerReplyException exceptionWithClass: [self class]]; } if (toRead == 0) { [sock close]; atEndOfStream = YES; } objc_autoreleasePoolPop(pool); return 0; } } - (BOOL)lowlevelIsAtEndOfStream { if (!chunked) return [sock isAtEndOfStream]; return atEndOfStream; } - (int)fileDescriptorForReading { return [sock fileDescriptorForReading]; } - (size_t)pendingBytes { return [super pendingBytes] + [sock pendingBytes]; } - (void)close { [sock close]; } @end @implementation OFHTTPClient + (instancetype)client { return [[[self alloc] init] autorelease]; } |
︙ | |||
175 176 177 178 179 180 181 | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | - - + + - + + | if (requestType == OF_HTTP_REQUEST_TYPE_POST) type = "POST"; if ([(path = [URL path]) length] == 0) path = @"/"; if ([URL query] != nil) |
︙ | |||
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | + + - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + | return [self performRequest: newRequest redirects: redirects - 1]; } [serverHeaders setObject: value forKey: key]; } [serverHeaders makeImmutable]; if ([delegate respondsToSelector: @selector(client:didReceiveHeaders:statusCode:request:)]) [delegate client: self didReceiveHeaders: serverHeaders statusCode: status request: request]; |
Modified src/OFHTTPRequest.h from [ffcaf67e5f] to [eeab32f289].
︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 31 32 33 34 35 36 37 38 39 40 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 | + + + + + + + + + + + + | OF_HTTP_REQUEST_TYPE_GET, /*! POST */ OF_HTTP_REQUEST_TYPE_POST, /*! HEAD */ OF_HTTP_REQUEST_TYPE_HEAD } of_http_request_type_t; /*! * @brief The HTTP version of the HTTP request. */ typedef struct of_http_request_protocol_version_t { /*! The major of the HTTP version */ uint8_t major; /*! The minor of the HTTP version */ uint8_t minor; } of_http_request_protocol_version_t; /*! * @brief A class for storing HTTP requests. */ @interface OFHTTPRequest: OFObject { OFURL *URL; of_http_request_type_t requestType; of_http_request_protocol_version_t protocolVersion; OFDictionary *headers; OFDataArray *POSTData; OFString *MIMEType; OFString *remoteAddress; } #ifdef OF_HAVE_PROPERTIES @property (copy) OFURL *URL; @property of_http_request_type_t requestType; @property of_http_request_protocol_version_t protocolVersion; @property (copy) OFDictionary *headers; @property (retain) OFDataArray *POSTData; @property (copy) OFString *MIMEType; @property (copy) OFString *remoteAddress; #endif /*! |
︙ | |||
104 105 106 107 108 109 110 111 112 113 114 115 116 117 | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | /*! * @brief Returns the request type of the HTTP request. * * @return The request type of the HTTP request */ - (of_http_request_type_t)requestType; /*! * @brief Sets the protocol version of the HTTP request. * * @param protocolVersion The protocol version of the HTTP request */ - (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion; /*! * @brief Returns the protocol version of the HTTP request. * * @return The protocol version of the HTTP request */ - (of_http_request_protocol_version_t)protocolVersion; /*! * @brief Sets the protocol version of the HTTP request to the version * described by the specified string. * * @param string A string describing an HTTP version */ - (void)setProtocolVersionFromString: (OFString*)string; /*! * @brief Returns the protocol version of the HTTP request as a string. * * @return The protocol version of the HTTP request as a string */ - (OFString*)protocolVersionString; /*! * @brief Sets a dictionary with headers for the HTTP request. * * @param headers A dictionary with headers for the HTTP request */ - (void)setHeaders: (OFDictionary*)headers; |
︙ |
Modified src/OFHTTPRequest.m from [ca52e82353] to [69b973a377].
︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | + + + + + + + | #include "config.h" #import "OFHTTPRequest.h" #import "OFString.h" #import "OFURL.h" #import "OFDictionary.h" #import "OFDataArray.h" #import "OFArray.h" #import "autorelease.h" #import "macros.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnsupportedVersionException.h" @implementation OFHTTPRequest + (instancetype)request { return [[[self alloc] init] autorelease]; } + (instancetype)requestWithURL: (OFURL*)URL { return [[[self alloc] initWithURL: URL] autorelease]; } - init { self = [super init]; requestType = OF_HTTP_REQUEST_TYPE_GET; protocolVersion.major = 1; protocolVersion.minor = 1; return self; } - initWithURL: (OFURL*)URL_ { self = [self init]; |
︙ | |||
85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | requestType = requestType_; } - (of_http_request_type_t)requestType { return requestType; } - (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion_ { if (protocolVersion_.major != 1 || protocolVersion.minor > 1) @throw [OFUnsupportedVersionException exceptionWithClass: [self class] version: [OFString stringWithFormat: @"%u.%u", protocolVersion_.major, protocolVersion_.minor]]; protocolVersion = protocolVersion_; } - (of_http_request_protocol_version_t)protocolVersion { return protocolVersion; } - (void)setProtocolVersionFromString: (OFString*)string { void *pool = objc_autoreleasePoolPush(); OFArray *components = [string componentsSeparatedByString: @"."]; intmax_t major, minor; of_http_request_protocol_version_t protocolVersion_; if ([components count] != 2) @throw [OFInvalidFormatException exceptionWithClass: [self class]]; major = [[components firstObject] decimalValue]; minor = [[components lastObject] decimalValue]; if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; protocolVersion_.major = (uint8_t)major; protocolVersion_.minor = (uint8_t)minor; [self setProtocolVersion: protocolVersion_]; objc_autoreleasePoolPop(pool); } - (OFString*)protocolVersionString { return [OFString stringWithFormat: @"%u.%u", protocolVersion.major, protocolVersion.minor]; } - (void)setHeaders: (OFDictionary*)headers_ { OF_SETTER(headers, headers_, YES, 1) } - (OFDictionary*)headers |
︙ |
Modified src/OFHTTPRequestReply.h from [ddd39acc1c] to [7576232cb8].
︙ | |||
10 11 12 13 14 15 16 | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | - + + - - + - + + - + - - + + - - + - - - - + + + + + + + + - - - + - + + - - + + + + - - + + + + - - - + - + - + + + + + + + + - + - + - + - + - + | * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ |
Modified src/OFHTTPRequestReply.m from [5a4bde7403] to [eadf4aca10].
︙ | |||
14 15 16 17 18 19 20 | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | - - + + - - + + - - - - - + - - - - + + + - - - - + - - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - + | * file. */ #include "config.h" #import "OFHTTPRequestReply.h" #import "OFString.h" |
Modified src/OFHTTPServer.h from [4cb8dc3eba] to [3553c698ef].
︙ | |||
28 29 30 31 32 33 34 | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | - + - - + + + | @protocol OFHTTPServerDelegate <OFObject> /*! * @brief This method is called when the HTTP server received a request from a * client. * * @param server The HTTP server which received the request * @param request The request the HTTP server received |
︙ |
Modified src/OFHTTPServer.m from [34f30ba48f] to [3a7faef063].
︙ | |||
37 38 39 40 41 42 43 | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | - | #import "OFWriteFailedException.h" #import "macros.h" #define BUFFER_SIZE 1024 /* |
︙ | |||
159 160 161 162 163 164 165 166 167 168 169 170 171 172 | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 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 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | firstLetter = NO; tmp++; } return [OFString stringWithUTF8StringNoCopy: cString freeWhenDone: YES]; } @interface OFHTTPServerReply: OFHTTPRequestReply { OFTCPSocket *sock; OFHTTPServer *server; BOOL chunked, headersSent, closed; } - initWithSocket: (OFTCPSocket*)sock server: (OFHTTPServer*)server; @end @implementation OFHTTPServerReply - initWithSocket: (OFTCPSocket*)sock_ server: (OFHTTPServer*)server_ { self = [super init]; statusCode = 500; sock = [sock_ retain]; server = [server_ retain]; return self; } - (void)dealloc { if (!closed) [self close]; [sock release]; [server release]; [super dealloc]; } - (void)sendHeaders { void *pool = objc_autoreleasePoolPush(); OFString *date = [[OFDate date] dateStringWithFormat: @"%a, %d %b %Y %H:%M:%S GMT"]; OFEnumerator *keyEnumerator, *valueEnumerator; OFString *key, *value; [sock writeFormat: @"HTTP/%@ %d %s\r\n" @"Server: %@\r\n" @"Date: %@\r\n", [self protocolVersionString], statusCode, status_code_to_string(statusCode), [server name], date]; keyEnumerator = [headers keyEnumerator]; valueEnumerator = [headers objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (value = [valueEnumerator nextObject]) != nil) if (![key isEqual: @"Server"] && ![key isEqual: @"Date"]) [sock writeFormat: @"%@: %@\r\n", key, value]; [sock writeString: @"\r\n"]; headersSent = YES; chunked = [[headers objectForKey: @"Transfer-Encoding"] isEqual: @"chunked"]; objc_autoreleasePoolPop(pool); } - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { void *pool; if (!headersSent) [self sendHeaders]; if (!chunked) { [sock writeBuffer: buffer length: length]; return; } pool = objc_autoreleasePoolPush(); [sock writeString: [OFString stringWithFormat: @"%zx\r\n", length]]; objc_autoreleasePoolPop(pool); [sock writeBuffer: buffer length: length]; [sock writeBuffer: "\r\n" length: 2]; } - (void)close { if (!headersSent) [self sendHeaders]; if (chunked) [sock writeBuffer: "0\r\n\r\n" length: 5]; [sock close]; closed = YES; } - (int)fileDescriptorForWriting { return [sock fileDescriptorForWriting]; } @end @interface OFHTTPServer_Connection: OFObject { OFTCPSocket *sock; OFHTTPServer *server; OFTimer *timer; enum { |
︙ | |||
191 192 193 194 195 196 197 | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | - + | - (BOOL)parseProlog: (OFString*)line; - (BOOL)parseHeaders: (OFString*)line; - (BOOL)socket: (OFTCPSocket*)sock didReadIntoBuffer: (const char*)buffer length: (size_t)length exception: (OFException*)exception; - (BOOL)sendErrorAndClose: (short)statusCode; |
︙ | |||
250 251 252 253 254 255 256 | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | - + | case AWAITING_PROLOG: return [self parseProlog: line]; case PARSING_HEADERS: if (![self parseHeaders: line]) return NO; if (state == SEND_REPLY) { |
︙ | |||
419 420 421 422 423 424 425 | 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | - + | return NO; [POSTData addItems: buffer count: length]; if ([POSTData count] >= contentLength) { @try { |
︙ | |||
448 449 450 451 452 453 454 | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | - + - + - - - - - | statusCode, status_code_to_string(statusCode), date, [server name]]; [sock close]; return NO; } |
︙ | |||
493 494 495 496 497 498 499 500 501 502 503 | 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | + + - - - + - - - + - - - - - - - + - - - - - - - - - + - - - - + - - - - - - - + - - - - - | [URL setPath: path_]; [URL setQuery: query]; } else [URL setPath: path]; request = [OFHTTPRequest requestWithURL: URL]; [request setRequestType: requestType]; [request setProtocolVersion: (of_http_request_protocol_version_t){ 1, HTTPMinorVersion }]; [request setHeaders: headers]; [request setPOSTData: POSTData]; [request setRemoteAddress: [sock remoteAddress]]; |
︙ |
Modified src/OFString.m from [7077269c5c] to [537b9ea7bb].
︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | + | #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFOpenFileFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFTruncatedDataException.h" #import "autorelease.h" #import "macros.h" #import "of_asprintf.h" #import "unicode.h" /* |
︙ | |||
897 898 899 900 901 902 903 | 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 | + - + + | - initWithContentsOfURL: (OFURL*)URL encoding: (of_string_encoding_t)encoding { void *pool; OFHTTPClient *client; OFHTTPRequest *request; OFHTTPRequestReply *reply; OFDictionary *headers; |
︙ | |||
924 925 926 927 928 929 930 931 932 | 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 | + + - + + + + + + + + - + - + + | reply = [client performRequest: request]; if ([reply statusCode] != 200) @throw [OFHTTPRequestFailedException exceptionWithClass: [request class] request: request reply: reply]; headers = [reply headers]; if (encoding == OF_STRING_ENCODING_AUTODETECT && |
︙ |
Modified tests/OFHTTPClientTests.m from [1c3e517f32] to [70f5e875cd].
︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | + | #import "OFHTTPRequestReply.h" #import "OFString.h" #import "OFTCPSocket.h" #import "OFThread.h" #import "OFCondition.h" #import "OFURL.h" #import "OFDictionary.h" #import "OFDataArray.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" static OFString *module = @"OFHTTPClient"; static OFCondition *cond; |
︙ | |||
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | + - + + + + + | { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFHTTPClientTestsServer *server; OFURL *url; OFHTTPClient *client; OFHTTPRequest *request; OFHTTPRequestReply *reply; OFDataArray *data; cond = [OFCondition condition]; [cond lock]; server = [[[OFHTTPClientTestsServer alloc] init] autorelease]; [server start]; [cond wait]; [cond unlock]; url = [OFURL URLWithString: [OFString stringWithFormat: @"http://127.0.0.1:%" @PRIu16 "/foo", server->port]]; TEST(@"-[performRequest:]", R(client = [OFHTTPClient client]) && R(request = [OFHTTPRequest requestWithURL: url]) && R(reply = [client performRequest: request])) TEST(@"Normalization of server header keys", |