Differences From Artifact [eadf4aca10]:
- File
src/OFHTTPRequestReply.m
— part of check-in
[bdf9c4d96b]
at
2013-01-26 00:13:56
on branch trunk
— Make OFHTTPRequestReply a stream.
This also implements chunked transfer encoding for OFHTTPServer and adds
a property for the protocol version to OFHTTPRequest(Reply).Additionally, this makes it possible to add an async version of
OFHTTPClient. (user: js, size: 3141) [annotate] [blame] [check-ins using]
To Artifact [bae34e8d9b]:
- File src/OFHTTPRequestReply.m — part of check-in [e40729d406] at 2013-02-12 18:22:15 on branch trunk — Prefix all ivars with an underscore. (user: js, size: 3141) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
29 30 31 32 33 34 35 | #import "OFUnsupportedVersionException.h" @implementation OFHTTPRequestReply - init { self = [super init]; | | | | | | | | | | | | | | | | | | | | | | | | | 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 | #import "OFUnsupportedVersionException.h" @implementation OFHTTPRequestReply - init { self = [super init]; _protocolVersion.major = 1; _protocolVersion.minor = 1; return self; } - (void)dealloc { [_headers release]; [super dealloc]; } - (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]; } - (short)statusCode { return _statusCode; } - (void)setStatusCode: (short)statusCode { _statusCode = statusCode; } - (OFDictionary*)headers { OF_GETTER(_headers, YES) } - (void)setHeaders: (OFDictionary*)headers { OF_SETTER(_headers, headers, YES, YES) } - (OFString*)description { void *pool = objc_autoreleasePoolPush(); OFString *indentedHeaders, *ret; indentedHeaders = [[_headers description] stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; ret = [[OFString alloc] initWithFormat: @"<%@:\n" @"\tStatus code = %d\n" @"\tHeaders = %@\n" @">", [self class], _statusCode, indentedHeaders]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end |