(declare (block) (standard-bindings) (extended-bindings))
(begin
  (define std/web/rack#start-rack-fastcgi-server!
    (lambda (_address208414_ _handler208415_)
      (std/web/fastcgi#start-fastcgi-server!
       _address208414_
       (lambda (_g208416208418_)
         (std/web/rack#rack-fastcgi-respond
          _g208416208418_
          _handler208415_)))))
  (define std/web/rack#rack-fastcgi-respond
    (lambda (_req208285_ _handler208286_)
      (letrec ((_collect-data208288_
                (lambda (_body208372_)
                  (let ((_out208374_ (open-output-u8vector)))
                    (let ((_iterable208397_ _body208372_)
                          (_iter-do208399_
                           (lambda (_val208376_)
                             (let* ((_val208378208383_ _val208376_)
                                    (_E208380208387_
                                     (lambda ()
                                       (error '"No clause matching"
                                              _val208378208383_)))
                                    (_K208381208392_
                                     (lambda (_next208390_)
                                       (if (u8vector? _next208390_)
                                           (write-subu8vector
                                            _next208390_
                                            '0
                                            (u8vector-length _next208390_)
                                            _out208374_)
                                           (if (string? _next208390_)
                                               (write-substring
                                                _next208390_
                                                '0
                                                (string-length _next208390_)
                                                _out208374_)
                                               (std/error#raise-io-error
                                                'rack-fastcgi-respond
                                                '"bad response chunk"
                                                _next208390_)))))
                                    (_next208395_ _val208378208383_))
                               (_K208381208392_ _next208395_)))))
                      (if (pair? _iterable208397_)
                          (for-each _iter-do208399_ _iterable208397_)
                          (let ((_$e208402_ (null? _iterable208397_)))
                            (if _$e208402_
                                _$e208402_
                                (let ((_it208405_
                                       (std/iter#iter _iterable208397_)))
                                  (let _lp208408_ ()
                                    (let ((_val208412_
                                           (std/iter#iter-next! _it208405_)))
                                      (if (eq? std/iter#iter-end _val208412_)
                                          '#!void
                                          (begin
                                            (_iter-do208399_ _val208412_)
                                            (_lp208408_)))))
                                  (std/iter#iter-fini! _it208405_)
                                  '#!void)))))
                    (get-output-u8vector _out208374_))))
               (_log-response-error208289_
                (lambda (_e208364_)
                  (std/logger#log-error '"rack response error" _e208364_)
                  (let ((_errstr208370_
                         (call-with-output-string
                          '()
                          (lambda (_g208365208367_)
                            (display-exception _e208364_ _g208365208367_)))))
                    (std/web/fastcgi#fastcgi-write-stderr
                     _req208285_
                     _errstr208370_)))))
        (with-exception-catcher
         (lambda (_g208290208292_)
           (if '#t
               (let ((_e208295_ _g208290208292_))
                 (_log-response-error208289_ _e208295_))
               (raise _g208290208292_)))
         (lambda ()
           (let ((_g208420_
                  (with-exception-catcher
                   (lambda (_g208297208299_)
                     (if '#t
                         (let ((_e208302_ _g208297208299_))
                           (_log-response-error208289_ _e208302_)
                           (values '500 '() '"OOPS! Something went wrong."))
                         (raise _g208297208299_)))
                   (lambda ()
                     (_handler208286_
                      (##structure-ref
                       _req208285_
                       '5
                       std/web/fastcgi#fastcgi-request::t
                       '#f)
                      (##structure-ref
                       _req208285_
                       '6
                       std/web/fastcgi#fastcgi-request::t
                       '#f))))))
             (begin
               (let ((_g208421_
                      (if (##values? _g208420_)
                          (##vector-length _g208420_)
                          1)))
                 (if (not (##fx= _g208421_ 3))
                     (error "Context expects 3 values" _g208421_)))
               (let ((_status208305_ (##vector-ref _g208420_ 0))
                     (_headers208306_ (##vector-ref _g208420_ 1))
                     (_body208307_ (##vector-ref _g208420_ 2)))
                 (let* ((_status-text208309_
                         (table-ref
                          std/web/rack#*http-response-codes*
                          _status208305_
                          '"(Unknown)"))
                        (_body-data208311_
                         (if (u8vector? _body208307_)
                             _body208307_
                             (if (string? _body208307_)
                                 (std/text/utf8#string->utf8__0 _body208307_)
                                 (_collect-data208288_ _body208307_))))
                        (_hout208313_ (open-output-u8vector)))
                   (std/format#fprintf
                    _hout208313_
                    '"Status: ~a ~a\r\n"
                    _status208305_
                    _status-text208309_)
                   (let ((_iterable208347_ _headers208306_)
                         (_iter-do208349_
                          (lambda (_val208316_)
                            (let* ((_val208318208325_ _val208316_)
                                   (_E208320208329_
                                    (lambda ()
                                      (error '"No clause matching"
                                             _val208318208325_)))
                                   (_K208321208335_
                                    (lambda (_value208332_ _key208333_)
                                      (std/format#fprintf
                                       _hout208313_
                                       '"~a: ~a\r\n"
                                       _key208333_
                                       _value208332_))))
                              (if (##pair? _val208318208325_)
                                  (let ((_hd208322208338_
                                         (##car _val208318208325_))
                                        (_tl208323208340_
                                         (##cdr _val208318208325_)))
                                    (let* ((_key208343_ _hd208322208338_)
                                           (_value208345_ _tl208323208340_))
                                      (_K208321208335_
                                       _value208345_
                                       _key208343_)))
                                  (_E208320208329_))))))
                     (if (pair? _iterable208347_)
                         (for-each _iter-do208349_ _iterable208347_)
                         (let ((_$e208352_ (null? _iterable208347_)))
                           (if _$e208352_
                               _$e208352_
                               (let ((_it208355_
                                      (std/iter#iter _iterable208347_)))
                                 (let _lp208358_ ()
                                   (let ((_val208362_
                                          (std/iter#iter-next! _it208355_)))
                                     (if (eq? std/iter#iter-end _val208362_)
                                         '#!void
                                         (begin
                                           (_iter-do208349_ _val208362_)
                                           (_lp208358_)))))
                                 (std/iter#iter-fini! _it208355_)
                                 '#!void)))))
                   (std/format#fprintf
                    _hout208313_
                    '"Content-Length: ~a\r\n"
                    (u8vector-length _body-data208311_))
                   (std/format#fprintf _hout208313_ '"\r\n")
                   (std/web/fastcgi#fastcgi-write-stdout
                    _req208285_
                    (get-output-u8vector _hout208313_))
                   (std/web/fastcgi#fastcgi-write-stdout
                    _req208285_
                    _body-data208311_))))))))))
  (define std/web/rack#*http-response-codes*
    (let ((_ht208282_ (make-table 'test: eq? 'size: '40)))
      (table-set! _ht208282_ '100 '"Continue")
      (table-set! _ht208282_ '101 '"Switching Protocols")
      (table-set! _ht208282_ '200 '"OK")
      (table-set! _ht208282_ '201 '"Created")
      (table-set! _ht208282_ '202 '"Accepted")
      (table-set! _ht208282_ '203 '"Non-Authoritative Information")
      (table-set! _ht208282_ '204 '"No Content")
      (table-set! _ht208282_ '205 '"Reset Content")
      (table-set! _ht208282_ '206 '"Partial Content")
      (table-set! _ht208282_ '300 '"Multiple Choices")
      (table-set! _ht208282_ '301 '"Moved Permanently")
      (table-set! _ht208282_ '302 '"Found")
      (table-set! _ht208282_ '303 '"See Other")
      (table-set! _ht208282_ '304 '"Not Modified")
      (table-set! _ht208282_ '305 '"Use Proxy")
      (table-set! _ht208282_ '307 '"Temporary Redirect")
      (table-set! _ht208282_ '400 '"Bad Request")
      (table-set! _ht208282_ '401 '"Unauthorized")
      (table-set! _ht208282_ '402 '"Payment Required")
      (table-set! _ht208282_ '403 '"Forbidden")
      (table-set! _ht208282_ '404 '"Not Found")
      (table-set! _ht208282_ '405 '"Method Not Allowed")
      (table-set! _ht208282_ '406 '"Not Acceptable")
      (table-set! _ht208282_ '407 '"Proxy Authentication Required")
      (table-set! _ht208282_ '408 '"Request Timeout")
      (table-set! _ht208282_ '409 '"Conflict")
      (table-set! _ht208282_ '410 '"Gone")
      (table-set! _ht208282_ '411 '"Length Required")
      (table-set! _ht208282_ '412 '"Precondition Failed")
      (table-set! _ht208282_ '413 '"Request Entity Too Large")
      (table-set! _ht208282_ '414 '"Request-URI Too Long")
      (table-set! _ht208282_ '415 '"Unsupported Media Type")
      (table-set! _ht208282_ '416 '"Requested Range Not Satisfiable")
      (table-set! _ht208282_ '417 '"Expectation Failed")
      (table-set! _ht208282_ '500 '"Internal Server Error")
      (table-set! _ht208282_ '501 '"Not Implemented")
      (table-set! _ht208282_ '502 '"Bad Gateway")
      (table-set! _ht208282_ '503 '"Service Unavailable")
      (table-set! _ht208282_ '504 '"Gateway Timeout")
      (table-set! _ht208282_ '505 '"HTTP Version Not Supported")
      _ht208282_)))
