(declare (block) (standard-bindings) (extended-bindings))
(begin
  (define std/web/rack#start-rack-fastcgi-server!
    (lambda (_address559_ _handler560_)
      (std/web/fastcgi#start-fastcgi-server!
       _address559_
       (lambda (_g561563_)
         (std/web/rack#rack-fastcgi-respond _g561563_ _handler560_)))))
  (define std/web/rack#rack-fastcgi-respond
    (lambda (_req412_ _handler413_)
      (letrec ((_collect-data415_
                (lambda (_body508_)
                  (let ((_out510_ (open-output-u8vector)))
                    (let ((_iterable533_ _body508_)
                          (_iter-do535_
                           (lambda (_val512_)
                             (let* ((_val514519_ _val512_)
                                    (_E516523_
                                     (lambda ()
                                       (error '"No clause matching"
                                              _val514519_)))
                                    (_K517528_
                                     (lambda (_next526_)
                                       (if (u8vector? _next526_)
                                           (write-subu8vector
                                            _next526_
                                            '0
                                            (u8vector-length _next526_)
                                            _out510_)
                                           (if (string? _next526_)
                                               (write-substring
                                                _next526_
                                                '0
                                                (string-length _next526_)
                                                _out510_)
                                               (std/error#raise-io-error
                                                'rack-fastcgi-respond
                                                '"bad response chunk"
                                                _next526_)))))
                                    (_next531_ _val514519_))
                               (_K517528_ _next531_)))))
                      (if (pair? _iterable533_)
                          (for-each _iter-do535_ _iterable533_)
                          (if (null? _iterable533_)
                              '#!void
                              (let* ((_it538_ (std/iter#iter _iterable533_))
                                     (_next!541_
                                      (let ()
                                        (declare (not safe))
                                        (##unchecked-structure-ref
                                         _it538_
                                         '2
                                         std/iter#iterator::t
                                         '#f))))
                                (declare (not safe))
                                (begin
                                  (let _lp546_ ()
                                    (let ((_val550_ (_next!541_ _it538_)))
                                      (if (eq? std/iter#iter-end _val550_)
                                          '#!void
                                          (begin
                                            (_iter-do535_ _val550_)
                                            (_lp546_)))))
                                  (let ((_$e552_ (##unchecked-structure-ref
                                                  _it538_
                                                  '3
                                                  std/iter#iterator::t
                                                  '#f)))
                                    (if _$e552_
                                        ((lambda (_g554556_)
                                           (_g554556_ _it538_))
                                         _$e552_)
                                        '#!void))
                                  '#!void)))))
                    (get-output-u8vector _out510_))))
               (_log-response-error416_
                (lambda (_e500_)
                  (std/logger#log-error '"rack response error" _e500_)
                  (let ((_errstr506_
                         (call-with-output-string
                          '()
                          (lambda (_g501503_)
                            (display-exception _e500_ _g501503_)))))
                    (std/web/fastcgi#fastcgi-write-stderr
                     _req412_
                     _errstr506_)))))
        (with-exception-catcher
         (lambda (_g417419_)
           (if '#t
               (let ((_e422_ _g417419_)) (_log-response-error416_ _e422_))
               (raise _g417419_)))
         (lambda ()
           (let ((_g4202_ (with-exception-catcher
                           (lambda (_g424426_)
                             (if '#t
                                 (let ((_e429_ _g424426_))
                                   (_log-response-error416_ _e429_)
                                   (values '500
                                           '()
                                           '"OOPS! Something went wrong."))
                                 (raise _g424426_)))
                           (lambda ()
                             (_handler413_
                              (##structure-ref
                               _req412_
                               '5
                               std/web/fastcgi#fastcgi-request::t
                               '#f)
                              (##structure-ref
                               _req412_
                               '6
                               std/web/fastcgi#fastcgi-request::t
                               '#f))))))
             (begin
               (let ((_g4203_ (let ()
                                (declare (not safe))
                                (if (##values? _g4202_)
                                    (##vector-length _g4202_)
                                    1))))
                 (if (not (let () (declare (not safe)) (##fx= _g4203_ 3)))
                     (error "Context expects 3 values" _g4203_)))
               (let ((_status432_
                      (let () (declare (not safe)) (##vector-ref _g4202_ 0)))
                     (_headers433_
                      (let () (declare (not safe)) (##vector-ref _g4202_ 1)))
                     (_body434_
                      (let () (declare (not safe)) (##vector-ref _g4202_ 2))))
                 (let* ((_status-text436_
                         (table-ref
                          std/web/rack#*http-response-codes*
                          _status432_
                          '"(Unknown)"))
                        (_body-data438_
                         (if (u8vector? _body434_)
                             _body434_
                             (if (string? _body434_)
                                 (std/text/utf8#string->utf8__0 _body434_)
                                 (_collect-data415_ _body434_))))
                        (_hout440_ (open-output-u8vector)))
                   (std/format#fprintf
                    _hout440_
                    '"Status: ~a ~a\r\n"
                    _status432_
                    _status-text436_)
                   (let ((_iterable474_ _headers433_)
                         (_iter-do476_
                          (lambda (_val443_)
                            (let* ((_val445452_ _val443_)
                                   (_E447456_
                                    (lambda ()
                                      (error '"No clause matching"
                                             _val445452_)))
                                   (_K448462_
                                    (lambda (_value459_ _key460_)
                                      (std/format#fprintf
                                       _hout440_
                                       '"~a: ~a\r\n"
                                       _key460_
                                       _value459_))))
                              (if (let ()
                                    (declare (not safe))
                                    (##pair? _val445452_))
                                  (let ((_hd449465_
                                         (let ()
                                           (declare (not safe))
                                           (##car _val445452_)))
                                        (_tl450467_
                                         (let ()
                                           (declare (not safe))
                                           (##cdr _val445452_))))
                                    (let* ((_key470_ _hd449465_)
                                           (_value472_ _tl450467_))
                                      (_K448462_ _value472_ _key470_)))
                                  (_E447456_))))))
                     (if (pair? _iterable474_)
                         (for-each _iter-do476_ _iterable474_)
                         (if (null? _iterable474_)
                             '#!void
                             (let* ((_it479_ (std/iter#iter _iterable474_))
                                    (_next!482_
                                     (let ()
                                       (declare (not safe))
                                       (##unchecked-structure-ref
                                        _it479_
                                        '2
                                        std/iter#iterator::t
                                        '#f))))
                               (declare (not safe))
                               (begin
                                 (let _lp487_ ()
                                   (let ((_val491_ (_next!482_ _it479_)))
                                     (if (eq? std/iter#iter-end _val491_)
                                         '#!void
                                         (begin
                                           (_iter-do476_ _val491_)
                                           (_lp487_)))))
                                 (let ((_$e493_ (##unchecked-structure-ref
                                                 _it479_
                                                 '3
                                                 std/iter#iterator::t
                                                 '#f)))
                                   (if _$e493_
                                       ((lambda (_g495497_)
                                          (_g495497_ _it479_))
                                        _$e493_)
                                       '#!void))
                                 '#!void)))))
                   (std/format#fprintf
                    _hout440_
                    '"Content-Length: ~a\r\n"
                    (u8vector-length _body-data438_))
                   (std/format#fprintf _hout440_ '"\r\n")
                   (std/web/fastcgi#fastcgi-write-stdout
                    _req412_
                    (get-output-u8vector _hout440_))
                   (std/web/fastcgi#fastcgi-write-stdout
                    _req412_
                    _body-data438_))))))))))
  (define std/web/rack#*http-response-codes*
    (let ((_ht409_ (make-table 'test: eq? 'size: '40)))
      (table-set! _ht409_ '100 '"Continue")
      (table-set! _ht409_ '101 '"Switching Protocols")
      (table-set! _ht409_ '200 '"OK")
      (table-set! _ht409_ '201 '"Created")
      (table-set! _ht409_ '202 '"Accepted")
      (table-set! _ht409_ '203 '"Non-Authoritative Information")
      (table-set! _ht409_ '204 '"No Content")
      (table-set! _ht409_ '205 '"Reset Content")
      (table-set! _ht409_ '206 '"Partial Content")
      (table-set! _ht409_ '300 '"Multiple Choices")
      (table-set! _ht409_ '301 '"Moved Permanently")
      (table-set! _ht409_ '302 '"Found")
      (table-set! _ht409_ '303 '"See Other")
      (table-set! _ht409_ '304 '"Not Modified")
      (table-set! _ht409_ '305 '"Use Proxy")
      (table-set! _ht409_ '307 '"Temporary Redirect")
      (table-set! _ht409_ '400 '"Bad Request")
      (table-set! _ht409_ '401 '"Unauthorized")
      (table-set! _ht409_ '402 '"Payment Required")
      (table-set! _ht409_ '403 '"Forbidden")
      (table-set! _ht409_ '404 '"Not Found")
      (table-set! _ht409_ '405 '"Method Not Allowed")
      (table-set! _ht409_ '406 '"Not Acceptable")
      (table-set! _ht409_ '407 '"Proxy Authentication Required")
      (table-set! _ht409_ '408 '"Request Timeout")
      (table-set! _ht409_ '409 '"Conflict")
      (table-set! _ht409_ '410 '"Gone")
      (table-set! _ht409_ '411 '"Length Required")
      (table-set! _ht409_ '412 '"Precondition Failed")
      (table-set! _ht409_ '413 '"Request Entity Too Large")
      (table-set! _ht409_ '414 '"Request-URI Too Long")
      (table-set! _ht409_ '415 '"Unsupported Media Type")
      (table-set! _ht409_ '416 '"Requested Range Not Satisfiable")
      (table-set! _ht409_ '417 '"Expectation Failed")
      (table-set! _ht409_ '500 '"Internal Server Error")
      (table-set! _ht409_ '501 '"Not Implemented")
      (table-set! _ht409_ '502 '"Bad Gateway")
      (table-set! _ht409_ '503 '"Service Unavailable")
      (table-set! _ht409_ '504 '"Gateway Timeout")
      (table-set! _ht409_ '505 '"HTTP Version Not Supported")
      _ht409_)))
