| 20 | headers.push('o'.repeat(i)); |
| 21 | |
| 22 | function WriteHTTPHeaders(channel, has_keep_alive, extra_header_count) { |
| 23 | todo = []; |
| 24 | todo.push('GET / HTTP/1.1'); |
| 25 | todo.push('Host: localhost'); |
| 26 | todo.push('Connection: keep-alive'); |
| 27 | todo.push('Accept: text/html,application/xhtml+xml,' + |
| 28 | 'application/xml;q=0.9,image/webp,*/*;q=0.8'); |
| 29 | todo.push('User-Agent: Mozilla/5.0 (X11; Linux x86_64) ' + |
| 30 | 'AppleWebKit/537.36 (KHTML, like Gecko) ' + |
| 31 | 'Chrome/39.0.2171.71 Safari/537.36'); |
| 32 | todo.push('Accept-Encoding: gzip, deflate, sdch'); |
| 33 | todo.push('Accept-Language: en-US,en;q=0.8'); |
| 34 | for (let i = 0; i < extra_header_count; i++) { |
| 35 | // Utilize first three powers of a small integer for an odd cycle and |
| 36 | // because the fourth power of some integers overloads the server. |
| 37 | todo.push(`X-Header-${i}: ${headers[i % 3]}`); |
| 38 | } |
| 39 | todo.push(''); |
| 40 | todo.push(''); |
| 41 | todo = todo.join('\r\n'); |
| 42 | // Using odd numbers in many places may increase length coverage. |
| 43 | const chunksize = 37; |
| 44 | for (let i = 0; i < todo.length; i += chunksize) { |
| 45 | const cur = todo.slice(i, i + chunksize); |
| 46 | channel.write(cur); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | const min = 10; |
| 51 | let size = 0; |