| OLD | NEW |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 | 29 |
| 30 from mod_pywebsocket import msgutil | 30 from mod_pywebsocket import msgutil |
| 31 | 31 |
| 32 | 32 |
| 33 def web_socket_do_extra_handshake(request): | 33 def web_socket_do_extra_handshake(request): |
| 34 # Exact number of headers that will fit in 256KB. Above 256KB an | 34 # Exact number of headers that will fit in 256KB. Above 256KB an |
| 35 # ERR_RESPONSE_HEADERS_TOO_BIG error is triggered instead. | 35 # ERR_RESPONSE_HEADERS_TOO_BIG error is triggered instead. |
| 36 for i in xrange(5978): | 36 |
| 37 request.extra_headers.append( | 37 name = 'Set-Cookie' |
| 38 ('Set-Cookie', 'WK-websocket-test-flood-%d=1' % i)) | 38 common_length = len(name + ': ' + '\r\n') |
| 39 |
| 40 i = 0 |
| 41 total_length = 0 |
| 42 while True: |
| 43 value = 'ws-%d=1' % i |
| 44 |
| 45 total_length += common_length + len(value) |
| 46 # Subtract 1KB to make sure we have space for the other headers. |
| 47 if total_length >= 256 * 1024 - 1024: |
| 48 break |
| 49 |
| 50 request.extra_headers.append((name, value)) |
| 51 i += 1 |
| 39 | 52 |
| 40 | 53 |
| 41 def web_socket_transfer_data(request): | 54 def web_socket_transfer_data(request): |
| 42 pass | 55 pass |
| OLD | NEW |