| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 if (url.port() && ((!secure && url.port() != 80) || (secure && url.port() !=
443))) { | 97 if (url.port() && ((!secure && url.port() != 80) || (secure && url.port() !=
443))) { |
| 98 builder.append(':'); | 98 builder.append(':'); |
| 99 builder.appendNumber(url.port()); | 99 builder.appendNumber(url.port()); |
| 100 } | 100 } |
| 101 return builder.toString(); | 101 return builder.toString(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 static const size_t maxInputSampleSize = 128; | 104 static const size_t maxInputSampleSize = 128; |
| 105 static String trimInputSample(const char* p, size_t len) | 105 static String trimInputSample(const char* p, size_t len) |
| 106 { | 106 { |
| 107 String s = String(p, std::min<size_t>(len, maxInputSampleSize)); | |
| 108 if (len > maxInputSampleSize) | 107 if (len > maxInputSampleSize) |
| 109 s.append(horizontalEllipsis); | 108 return String(p, maxInputSampleSize) + horizontalEllipsis; |
| 110 return s; | 109 return String(p, len); |
| 111 } | 110 } |
| 112 | 111 |
| 113 static String generateSecWebSocketKey() | 112 static String generateSecWebSocketKey() |
| 114 { | 113 { |
| 115 static const size_t nonceSize = 16; | 114 static const size_t nonceSize = 16; |
| 116 unsigned char key[nonceSize]; | 115 unsigned char key[nonceSize]; |
| 117 cryptographicallyRandomValues(key, nonceSize); | 116 cryptographicallyRandomValues(key, nonceSize); |
| 118 return base64Encode(reinterpret_cast<char*>(key), nonceSize); | 117 return base64Encode(reinterpret_cast<char*>(key), nonceSize); |
| 119 } | 118 } |
| 120 | 119 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 } | 580 } |
| 582 if (!match) { | 581 if (!match) { |
| 583 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec-
WebSocket-Protocol' header but no response was received"); | 582 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec-
WebSocket-Protocol' header but no response was received"); |
| 584 return false; | 583 return false; |
| 585 } | 584 } |
| 586 } | 585 } |
| 587 return true; | 586 return true; |
| 588 } | 587 } |
| 589 | 588 |
| 590 } // namespace WebCore | 589 } // namespace WebCore |
| OLD | NEW |