Overview
Comment: | OFHTTPRequest: Fix handling of remoteAddress |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8d78a77f79703d81994968a8d5683ff9 |
User & Date: | js on 2020-10-03 21:46:51 |
Other Links: | manifest | tags |
Context
2020-10-03
| ||
23:25 | OFURL: Add queryDictionary property check-in: a151f9c31f user: js tags: trunk | |
21:46 | OFHTTPRequest: Fix handling of remoteAddress check-in: 8d78a77f79 user: js tags: trunk | |
14:45 | tests/Makefile: Fix a typo check-in: df0c74b430 user: js tags: trunk | |
Changes
Modified src/OFHTTPRequest.h from [c1c1ccb441] to [345d23988c].
︙ | ︙ | |||
74 75 76 77 78 79 80 81 82 83 84 85 86 87 | @interface OFHTTPRequest: OFObject <OFCopying> { OFURL *_URL; of_http_request_method_t _method; of_http_request_protocol_version_t _protocolVersion; OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers; of_socket_address_t _remoteAddress; OF_RESERVE_IVARS(OFHTTPRequest, 4) } /** * @brief The URL of the HTTP request. */ @property (copy, nonatomic) OFURL *URL; | > | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | @interface OFHTTPRequest: OFObject <OFCopying> { OFURL *_URL; of_http_request_method_t _method; of_http_request_protocol_version_t _protocolVersion; OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers; of_socket_address_t _remoteAddress; bool _hasRemoteAddress; OF_RESERVE_IVARS(OFHTTPRequest, 4) } /** * @brief The URL of the HTTP request. */ @property (copy, nonatomic) OFURL *URL; |
︙ | ︙ |
Modified src/OFHTTPRequest.m from [a65b94e9ae] to [2b2b69fc08].
︙ | ︙ | |||
123 124 125 126 127 128 129 | [_headers release]; [super dealloc]; } - (void)setRemoteAddress: (const of_socket_address_t *)remoteAddress { | > > > | > | > > | | 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 | [_headers release]; [super dealloc]; } - (void)setRemoteAddress: (const of_socket_address_t *)remoteAddress { _hasRemoteAddress = (remoteAddress != NULL); if (_hasRemoteAddress) _remoteAddress = *remoteAddress; } - (const of_socket_address_t *)remoteAddress { if (_hasRemoteAddress) return &_remoteAddress; return NULL; } - (id)copy { OFHTTPRequest *copy = [[OFHTTPRequest alloc] init]; @try { copy->_method = _method; copy->_protocolVersion = _protocolVersion; copy.URL = _URL; copy.headers = _headers; copy.remoteAddress = self.remoteAddress; } @catch (id e) { [copy release]; @throw e; } return copy; } |
︙ | ︙ | |||
165 166 167 168 169 170 171 | request = object; if (request->_method != _method || request->_protocolVersion.major != _protocolVersion.major || request->_protocolVersion.minor != _protocolVersion.minor || ![request->_URL isEqual: _URL] || | | > > > | > | | 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 | request = object; if (request->_method != _method || request->_protocolVersion.major != _protocolVersion.major || request->_protocolVersion.minor != _protocolVersion.minor || ![request->_URL isEqual: _URL] || ![request->_headers isEqual: _headers]) return false; if (request.remoteAddress != self.remoteAddress && !of_socket_address_equal(request.remoteAddress, self.remoteAddress)) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD(hash, _method); OF_HASH_ADD(hash, _protocolVersion.major); OF_HASH_ADD(hash, _protocolVersion.minor); OF_HASH_ADD_HASH(hash, _URL.hash); OF_HASH_ADD_HASH(hash, _headers.hash); if (_hasRemoteAddress) OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_remoteAddress)); OF_HASH_FINALIZE(hash); return hash; } - (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion |
︙ | ︙ | |||
241 242 243 244 245 246 247 | _protocolVersion.minor]; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); const char *method = of_http_request_method_to_string(_method); | | > > > > > > | < | 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 282 | _protocolVersion.minor]; } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); const char *method = of_http_request_method_to_string(_method); OFString *indentedHeaders, *remoteAddress, *ret; indentedHeaders = [_headers.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; if (_hasRemoteAddress) remoteAddress = of_socket_address_ip_string(&_remoteAddress, NULL); else remoteAddress = nil; ret = [[OFString alloc] initWithFormat: @"<%@:\n\tURL = %@\n" @"\tMethod = %s\n" @"\tHeaders = %@\n" @"\tRemote address = %@\n" @">", self.class, _URL, method, indentedHeaders, remoteAddress]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end |