(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'test git-http-backend'>)}
          spids: [4]
        )
      ]
    )
    (C {<.>} {<./test-lib.sh>})
    (C {<.>} {(DQ ($ Id.VSub_DollarName '$TEST_DIRECTORY')) </lib-httpd.sh>})
    (C {<start_httpd>})
    (command.ShFunction
      name: GET
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.Simple
                  words: [
                    {<curl>}
                    {<--include>}
                    {
                      (DQ ($ Id.VSub_DollarName '$HTTPD_URL') </> ($ Id.VSub_DollarName '$SMART') 
                        </repo.git/> ($ Id.VSub_Number '$1')
                      )
                    }
                  ]
                  redirects: [
                    (redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<out>})
                    (redir.Redir
                      op: <Id.Redir_Great '2>'>
                      fd: 2
                      arg_word: {</dev/null>}
                    )
                  ]
                )
                (command.Pipeline
                  children: [
                    (command.Simple
                      words: [{<tr>} {(SQ <'\\015'>)} {<Q>}]
                      redirects: [(redir.Redir op:<Id.Redir_Less '<'> fd:-1 arg_word:{<out>})]
                    )
                    (command.Simple
                      words: [{<sed>} {(SQ <'\n'> <'\t\ts/Q$//\n'> <'\t\t1q\n'> <'\t'>)}]
                      redirects: [(redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<act>})]
                    )
                  ]
                  negated: F
                )
                (command.Simple
                  words: [{<echo>} {(DQ <'HTTP/1.1 '> ($ Id.VSub_Number '$2'))}]
                  redirects: [(redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<exp>})]
                )
                (C {<test_cmp>} {<exp>} {<act>})
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: POST
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.Simple
                  words: [
                    {<curl>}
                    {<--include>}
                    {<--data>}
                    {(DQ ($ Id.VSub_Number '$2'))}
                    {<--header>}
                    {(DQ <'Content-Type: application/x-'> ($ Id.VSub_Number '$1') <-request>)}
                    {
                      (DQ ($ Id.VSub_DollarName '$HTTPD_URL') </smart/repo.git/> 
                        ($ Id.VSub_Number '$1')
                      )
                    }
                  ]
                  redirects: [
                    (redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<out>})
                    (redir.Redir
                      op: <Id.Redir_Great '2>'>
                      fd: 2
                      arg_word: {</dev/null>}
                    )
                  ]
                )
                (command.Pipeline
                  children: [
                    (command.Simple
                      words: [{<tr>} {(SQ <'\\015'>)} {<Q>}]
                      redirects: [(redir.Redir op:<Id.Redir_Less '<'> fd:-1 arg_word:{<out>})]
                    )
                    (command.Simple
                      words: [{<sed>} {(SQ <'\n'> <'\t\ts/Q$//\n'> <'\t\t1q\n'> <'\t'>)}]
                      redirects: [(redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<act>})]
                    )
                  ]
                  negated: F
                )
                (command.Simple
                  words: [{<echo>} {(DQ <'HTTP/1.1 '> ($ Id.VSub_Number '$3'))}]
                  redirects: [(redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<exp>})]
                )
                (C {<test_cmp>} {<exp>} {<act>})
              ]
            )
          ]
        )
    )
    (C {<.>} {(DQ ($ Id.VSub_DollarName '$TEST_DIRECTORY')) </t556x_common>})
    (command.Simple
      words: [{<grep>} {(SQ <'^[^#]'>)}]
      redirects: [
        (redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<exp>})
        (redir.HereDoc
          op: <Id.Redir_DLess '<<'>
          fd: -1
          here_begin: {<EOF>}
          here_end_span_id: 337
          stdin_parts: [
            <'\n'>
            <'###  refs/heads/master\n'>
            <'###\n'>
            <'GET  /smart/repo.git/refs/heads/master HTTP/1.1 404 -\n'>
            <'\n'>
            <'###  getanyfile default\n'>
            <'###\n'>
            <'GET  /smart/repo.git/HEAD HTTP/1.1 200\n'>
            <'GET  /smart/repo.git/info/refs HTTP/1.1 200\n'>
            <'GET  /smart/repo.git/objects/info/packs HTTP/1.1 200\n'>
            <'GET  /smart/repo.git/objects/info/alternates HTTP/1.1 200 -\n'>
            <'GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -\n'>
            <'GET  /smart/repo.git/'>
            ($ Id.VSub_DollarName '$LOOSE_URL')
            <' HTTP/1.1 200\n'>
            <'GET  /smart/repo.git/'>
            ($ Id.VSub_DollarName '$PACK_URL')
            <' HTTP/1.1 200\n'>
            <'GET  /smart/repo.git/'>
            ($ Id.VSub_DollarName '$IDX_URL')
            <' HTTP/1.1 200\n'>
            <'\n'>
            <'###  no git-daemon-export-ok\n'>
            <'###\n'>
            <'GET  /smart_noexport/repo.git/HEAD HTTP/1.1 404 -\n'>
            <'GET  /smart_noexport/repo.git/info/refs HTTP/1.1 404 -\n'>
            <'GET  /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -\n'>
            <'GET  /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -\n'>
            <'GET  /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -\n'>
            <'GET  /smart_noexport/repo.git/'>
            ($ Id.VSub_DollarName '$LOOSE_URL')
            <' HTTP/1.1 404 -\n'>
            <'GET  /smart_noexport/repo.git/'>
            ($ Id.VSub_DollarName '$PACK_URL')
            <' HTTP/1.1 404 -\n'>
            <'GET  /smart_noexport/repo.git/'>
            ($ Id.VSub_DollarName '$IDX_URL')
            <' HTTP/1.1 404 -\n'>
            <'\n'>
            <'###  git-daemon-export-ok\n'>
            <'###\n'>
            <'GET  /smart_noexport/repo.git/HEAD HTTP/1.1 200\n'>
            <'GET  /smart_noexport/repo.git/info/refs HTTP/1.1 200\n'>
            <'GET  /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200\n'>
            <'GET  /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -\n'>
            <'GET  /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -\n'>
            <'GET  /smart_noexport/repo.git/'>
            ($ Id.VSub_DollarName '$LOOSE_URL')
            <' HTTP/1.1 200\n'>
            <'GET  /smart_noexport/repo.git/'>
            ($ Id.VSub_DollarName '$PACK_URL')
            <' HTTP/1.1 200\n'>
            <'GET  /smart_noexport/repo.git/'>
            ($ Id.VSub_DollarName '$IDX_URL')
            <' HTTP/1.1 200\n'>
            <'\n'>
            <'###  getanyfile true\n'>
            <'###\n'>
            <'GET  /smart/repo.git/HEAD HTTP/1.1 200\n'>
            <'GET  /smart/repo.git/info/refs HTTP/1.1 200\n'>
            <'GET  /smart/repo.git/objects/info/packs HTTP/1.1 200\n'>
            <'GET  /smart/repo.git/objects/info/alternates HTTP/1.1 200 -\n'>
            <'GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -\n'>
            <'GET  /smart/repo.git/'>
            ($ Id.VSub_DollarName '$LOOSE_URL')
            <' HTTP/1.1 200\n'>
            <'GET  /smart/repo.git/'>
            ($ Id.VSub_DollarName '$PACK_URL')
            <' HTTP/1.1 200\n'>
            <'GET  /smart/repo.git/'>
            ($ Id.VSub_DollarName '$IDX_URL')
            <' HTTP/1.1 200\n'>
            <'\n'>
            <'###  getanyfile false\n'>
            <'###\n'>
            <'GET  /smart/repo.git/HEAD HTTP/1.1 403 -\n'>
            <'GET  /smart/repo.git/info/refs HTTP/1.1 403 -\n'>
            <'GET  /smart/repo.git/objects/info/packs HTTP/1.1 403 -\n'>
            <'GET  /smart/repo.git/objects/info/alternates HTTP/1.1 403 -\n'>
            <'GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -\n'>
            <'GET  /smart/repo.git/'>
            ($ Id.VSub_DollarName '$LOOSE_URL')
            <' HTTP/1.1 403 -\n'>
            <'GET  /smart/repo.git/'>
            ($ Id.VSub_DollarName '$PACK_URL')
            <' HTTP/1.1 403 -\n'>
            <'GET  /smart/repo.git/'>
            ($ Id.VSub_DollarName '$IDX_URL')
            <' HTTP/1.1 403 -\n'>
            <'\n'>
            <'###  uploadpack default\n'>
            <'###\n'>
            <'GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n'>
            <'POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -\n'>
            <'\n'>
            <'###  uploadpack true\n'>
            <'###\n'>
            <'GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n'>
            <'POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -\n'>
            <'\n'>
            <'###  uploadpack false\n'>
            <'###\n'>
            <'GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -\n'>
            <'POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -\n'>
            <'\n'>
            <'###  receivepack default\n'>
            <'###\n'>
            <'GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -\n'>
            <'POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -\n'>
            <'\n'>
            <'###  receivepack true\n'>
            <'###\n'>
            <'GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200\n'>
            <'POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -\n'>
            <'\n'>
            <'###  receivepack false\n'>
            <'###\n'>
            <'GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -\n'>
            <'POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -\n'>
          ]
        )
      ]
    )
    (C {<test_expect_success>} {(SQ <'server request log matches test results'>)} 
      {
        (SQ <'\n'> <'\tsed -e "\n'> <'\t\ts/^.* \\"//\n'> <'\t\ts/\\"//\n'> <'\t\ts/ [1-9][0-9]*\\$//\n'> 
          <'\t\ts/^GET /GET  /\n'> <'\t" >act <"$HTTPD_ROOT_PATH"/access.log &&\n'> <'\ttest_cmp exp act\n'>
        )
      }
    )
    (C {<stop_httpd>})
    (C {<test_done>})
  ]
)