Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: webrtc/examples/objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.m

Issue 2721583002: iOS AppRTCMobile: Fix SocketRocket bug (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // 1 //
2 // Copyright 2012 Square Inc. 2 // Copyright 2012 Square Inc.
3 // 3 //
4 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License. 5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at 6 // You may obtain a copy of the License at
7 // 7 //
8 // http://www.apache.org/licenses/LICENSE-2.0 8 // http://www.apache.org/licenses/LICENSE-2.0
9 // 9 //
10 // Unless required by applicable law or agreed to in writing, software 10 // Unless required by applicable law or agreed to in writing, software
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 497
498 - (void)didConnect 498 - (void)didConnect
499 { 499 {
500 SRFastLog(@"Connected"); 500 SRFastLog(@"Connected");
501 CFHTTPMessageRef request = CFHTTPMessageCreateRequest(NULL, CFSTR("GET"), (_ _bridge CFURLRef)_url, kCFHTTPVersion1_1); 501 CFHTTPMessageRef request = CFHTTPMessageCreateRequest(NULL, CFSTR("GET"), (_ _bridge CFURLRef)_url, kCFHTTPVersion1_1);
502 502
503 // Set host first so it defaults 503 // Set host first so it defaults
504 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Host"), (__bridge CFStringR ef)(_url.port ? [NSString stringWithFormat:@"%@:%@", _url.host, _url.port] : _ur l.host)); 504 CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Host"), (__bridge CFStringR ef)(_url.port ? [NSString stringWithFormat:@"%@:%@", _url.host, _url.port] : _ur l.host));
505 505
506 NSMutableData *keyBytes = [[NSMutableData alloc] initWithLength:16]; 506 NSMutableData *keyBytes = [[NSMutableData alloc] initWithLength:16];
507 BOOL success = SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyByt es.mutableBytes); 507 BOOL success = !SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBy tes.mutableBytes);
508 assert(success); 508 assert(success);
509 509
510 if ([keyBytes respondsToSelector:@selector(base64EncodedStringWithOptions:)] ) { 510 if ([keyBytes respondsToSelector:@selector(base64EncodedStringWithOptions:)] ) {
511 _secKey = [keyBytes base64EncodedStringWithOptions:0]; 511 _secKey = [keyBytes base64EncodedStringWithOptions:0];
512 } else { 512 } else {
513 _secKey = [keyBytes base64Encoding]; 513 _secKey = [keyBytes base64Encoding];
514 } 514 }
515 515
516 assert([_secKey length] == 24); 516 assert([_secKey length] == 24);
517 517
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 frame_buffer_size += sizeof(uint64_t); 1355 frame_buffer_size += sizeof(uint64_t);
1356 } 1356 }
1357 1357
1358 if (!useMask) { 1358 if (!useMask) {
1359 for (size_t i = 0; i < payloadLength; i++) { 1359 for (size_t i = 0; i < payloadLength; i++) {
1360 frame_buffer[frame_buffer_size] = unmasked_payload[i]; 1360 frame_buffer[frame_buffer_size] = unmasked_payload[i];
1361 frame_buffer_size += 1; 1361 frame_buffer_size += 1;
1362 } 1362 }
1363 } else { 1363 } else {
1364 uint8_t *mask_key = frame_buffer + frame_buffer_size; 1364 uint8_t *mask_key = frame_buffer + frame_buffer_size;
1365 BOOL success = SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), ( uint8_t *)mask_key); 1365 BOOL success = !SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);
1366 assert(success); 1366 assert(success);
1367 frame_buffer_size += sizeof(uint32_t); 1367 frame_buffer_size += sizeof(uint32_t);
1368 1368
1369 // TODO: could probably optimize this with SIMD 1369 // TODO: could probably optimize this with SIMD
1370 for (size_t i = 0; i < payloadLength; i++) { 1370 for (size_t i = 0; i < payloadLength; i++) {
1371 frame_buffer[frame_buffer_size] = unmasked_payload[i] ^ mask_key[i % sizeof(uint32_t)]; 1371 frame_buffer[frame_buffer_size] = unmasked_payload[i] ^ mask_key[i % sizeof(uint32_t)];
1372 frame_buffer_size += 1; 1372 frame_buffer_size += 1;
1373 } 1373 }
1374 } 1374 }
1375 1375
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 } 1754 }
1755 } 1755 }
1756 1756
1757 - (NSRunLoop *)runLoop; 1757 - (NSRunLoop *)runLoop;
1758 { 1758 {
1759 dispatch_group_wait(_waitGroup, DISPATCH_TIME_FOREVER); 1759 dispatch_group_wait(_waitGroup, DISPATCH_TIME_FOREVER);
1760 return _runLoop; 1760 return _runLoop;
1761 } 1761 }
1762 1762
1763 @end 1763 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698