make `Switch` constructor more precise
[hiphop-php.git] / hphp / test / slow / ext_oauth / overflow_redir.php
blob149978957293bf991458d689dd96c504275357c0
1 <?hh
2 require 'server.inc';
3 <<__EntryPoint>> function main(): void {
4 $x = new OAuth('1234','1234');
5 $x->setRequestEngine(OAUTH_REQENGINE_CURL);
7 $output = null;
8 $port = random_free_port();
9 $pid = http_server("tcp://127.0.0.1:$port", varray[
10 "HTTP/1.0 302 Found\r\nLocation: http://127.0.0.1:$port/" . str_repeat('a', 512) . "bbb\r\n\r\n",
11 "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 40\r\n\r\noauth_token=1234&oauth_token_secret=4567",
12 ], inout $output);
14 try {
15 $x->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION);
16 var_dump($x->getRequestToken("http://127.0.0.1:$port/test", null, 'GET'));
17 } catch (Exception $e) {
18 var_dump($x->debugInfo);
20 fseek($output, 0, SEEK_SET);
22 // Split up the requests, make sure we sort the headers
23 // since we need to compare output but we don't care about
24 // the exact ordering.
25 $requests = explode("\r\n\r\n", trim(stream_get_contents($output)));
26 foreach ($requests as $cur_request) {
27 $request_headers = explode("\r\n", $cur_request);
28 var_dump(array_shift($request_headers));
29 sort($request_headers);
30 foreach ($request_headers as $cur_header) {
31 var_dump($cur_header);
35 http_server_kill($pid);