tests/test-http-api.t
changeset 37093 db114320df7e
parent 37046 1cfef5693203
child 38021 538e850ae737
equal deleted inserted replaced
37092:ef6215df2402 37093:db114320df7e
     6   $ hg -R server serve -p $HGPORT -d --pid-file hg.pid
     6   $ hg -R server serve -p $HGPORT -d --pid-file hg.pid
     7   $ cat hg.pid > $DAEMON_PIDS
     7   $ cat hg.pid > $DAEMON_PIDS
     8 
     8 
     9 Request to /api fails unless web.apiserver is enabled
     9 Request to /api fails unless web.apiserver is enabled
    10 
    10 
    11   $ send << EOF
    11   $ get-with-headers.py $LOCALIP:$HGPORT api
    12   > httprequest GET api
    12   400 no such method: api
    13   >     user-agent: test
    13   
    14   > EOF
    14   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    15   using raw connection to peer
    15   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
    16   s>     GET /api HTTP/1.1\r\n
    16   <head>
    17   s>     Accept-Encoding: identity\r\n
    17   <link rel="icon" href="/static/hgicon.png" type="image/png" />
    18   s>     user-agent: test\r\n
    18   <meta name="robots" content="index, nofollow" />
    19   s>     host: $LOCALIP:$HGPORT\r\n (glob)
    19   <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
    20   s>     \r\n
    20   <script type="text/javascript" src="/static/mercurial.js"></script>
    21   s> makefile('rb', None)
    21   
    22   s>     HTTP/1.1 404 Not Found\r\n
    22   <title>$TESTTMP/server: error</title>
    23   s>     Server: testing stub value\r\n
    23   </head>
    24   s>     Date: $HTTP_DATE$\r\n
    24   <body>
    25   s>     Content-Type: text/plain\r\n
    25   
    26   s>     Content-Length: 44\r\n
    26   <div class="container">
    27   s>     \r\n
    27   <div class="menu">
    28   s>     Experimental API server endpoint not enabled
    28   <div class="logo">
    29 
    29   <a href="https://mercurial-scm.org/">
    30   $ send << EOF
    30   <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
    31   > httprequest GET api/
    31   </div>
    32   >     user-agent: test
    32   <ul>
    33   > EOF
    33   <li><a href="/shortlog">log</a></li>
    34   using raw connection to peer
    34   <li><a href="/graph">graph</a></li>
    35   s>     GET /api/ HTTP/1.1\r\n
    35   <li><a href="/tags">tags</a></li>
    36   s>     Accept-Encoding: identity\r\n
    36   <li><a href="/bookmarks">bookmarks</a></li>
    37   s>     user-agent: test\r\n
    37   <li><a href="/branches">branches</a></li>
    38   s>     host: $LOCALIP:$HGPORT\r\n (glob)
    38   </ul>
    39   s>     \r\n
    39   <ul>
    40   s> makefile('rb', None)
    40   <li><a href="/help">help</a></li>
    41   s>     HTTP/1.1 404 Not Found\r\n
    41   </ul>
    42   s>     Server: testing stub value\r\n
    42   </div>
    43   s>     Date: $HTTP_DATE$\r\n
    43   
    44   s>     Content-Type: text/plain\r\n
    44   <div class="main">
    45   s>     Content-Length: 44\r\n
    45   
    46   s>     \r\n
    46   <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
    47   s>     Experimental API server endpoint not enabled
    47   <h3>error</h3>
       
    48   
       
    49   
       
    50   <form class="search" action="/log">
       
    51   
       
    52   <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
       
    53   <div id="hint">Find changesets by keywords (author, files, the commit message), revision
       
    54   number or hash, or <a href="/help/revsets">revset expression</a>.</div>
       
    55   </form>
       
    56   
       
    57   <div class="description">
       
    58   <p>
       
    59   An error occurred while processing your request:
       
    60   </p>
       
    61   <p>
       
    62   no such method: api
       
    63   </p>
       
    64   </div>
       
    65   </div>
       
    66   </div>
       
    67   
       
    68   
       
    69   
       
    70   </body>
       
    71   </html>
       
    72   
       
    73   [1]
       
    74 
       
    75   $ get-with-headers.py $LOCALIP:$HGPORT api/
       
    76   400 no such method: api
       
    77   
       
    78   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
       
    79   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
       
    80   <head>
       
    81   <link rel="icon" href="/static/hgicon.png" type="image/png" />
       
    82   <meta name="robots" content="index, nofollow" />
       
    83   <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
       
    84   <script type="text/javascript" src="/static/mercurial.js"></script>
       
    85   
       
    86   <title>$TESTTMP/server: error</title>
       
    87   </head>
       
    88   <body>
       
    89   
       
    90   <div class="container">
       
    91   <div class="menu">
       
    92   <div class="logo">
       
    93   <a href="https://mercurial-scm.org/">
       
    94   <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
       
    95   </div>
       
    96   <ul>
       
    97   <li><a href="/shortlog">log</a></li>
       
    98   <li><a href="/graph">graph</a></li>
       
    99   <li><a href="/tags">tags</a></li>
       
   100   <li><a href="/bookmarks">bookmarks</a></li>
       
   101   <li><a href="/branches">branches</a></li>
       
   102   </ul>
       
   103   <ul>
       
   104   <li><a href="/help">help</a></li>
       
   105   </ul>
       
   106   </div>
       
   107   
       
   108   <div class="main">
       
   109   
       
   110   <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
       
   111   <h3>error</h3>
       
   112   
       
   113   
       
   114   <form class="search" action="/log">
       
   115   
       
   116   <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
       
   117   <div id="hint">Find changesets by keywords (author, files, the commit message), revision
       
   118   number or hash, or <a href="/help/revsets">revset expression</a>.</div>
       
   119   </form>
       
   120   
       
   121   <div class="description">
       
   122   <p>
       
   123   An error occurred while processing your request:
       
   124   </p>
       
   125   <p>
       
   126   no such method: api
       
   127   </p>
       
   128   </div>
       
   129   </div>
       
   130   </div>
       
   131   
       
   132   
       
   133   
       
   134   </body>
       
   135   </html>
       
   136   
       
   137   [1]
    48 
   138 
    49 Restart server with support for API server
   139 Restart server with support for API server
    50 
   140 
    51   $ killdaemons.py
   141   $ killdaemons.py
    52   $ cat > server/.hg/hgrc << EOF
   142   $ cat > server/.hg/hgrc << EOF