(require scgi) (cgi #:startup (lambda () (printf "Startup for cgi-type ~S..." (cgi-type))) #:request (lambda () (display "Content-type: text/html\r\n\r\n") (display "<p>Hello, world!</p>") (printf "<p>Your IP address is: ~S</p>" (cgi-remote-addr))) #:shutdown (lambda () (printf "Shutdown for cgi-type ~S..." (cgi-type))))
startup-proc : (-> any) = void request-proc : (-> any) shutdown-proc : (-> any) = void scgi-hostname : (or/c string? #f) = "127.0.0.1" scgi-max-allow-wait : exact-nonnegative-integer? = 4
(and/c exact-nonnegative-integer? (integer-in 0 65535)) = 4000 reuse-scgi-port? : boolean? = #t
(define cgi-remote-user (make-cgi-variable-proc 'cgi-remote-user #"REMOTE_USER"))
LoadModule scgi_module /usr/lib/apache2/modules/mod_scgi.so
SCGIMount /mypath 127.0.0.1:4000
Racket error “tcp-write: error writing (Broken pipe; errno=32)” or “tcp-write: error writing (Connection reset by peer; errno=104)” is likely due to the HTTP request having been dropped by the HTTP client (e.g., user stops a page load in their browser before page finishes loading) or by Apache hitting SCGIServerTimeout for the request. Note that buffered I/O means that you won’t necessarily get this error even if the request is aborted this way.
Apache error log entry “Premature end of script headers: PATH” followed by “(500)Unknown error 500: scgi: Unknown error 500: error reading response headers” can mean that SCGIServerTimeout was hit before any HTTP headers from the SCGI request handler were started or completed. Note that buffered I/O can mean that some of the Racket code of the handler wrote some text, but it was not yet flushed to the SCGI client.
Apache error log entry “(70007)The timeout specified has expired: ap_content_length_filter: apr_bucket_read() failed” followed by “(70007)The timeout specified has expired: scgi: The timeout specified has expired: ap_pass_brigade()” can mean that SCGIServerTimeout was hit after HTTP headers from the request handler had been received by the SCGI client.
Apache error log entry “(32)Broken pipe: scgi: Broken pipe: error sending request body” might be due to a request handler finished without consuming all of the HTTP POST data.
Apache error log entry “(103)Software caused connection abort: scgi: Software caused connection abort: ap_pass_brigade()” is another one that can be caused by the HTTP client dropping the connection before the handler finishes.
- Version 3:3 —
Tweaked info.rkt, filenames.
- Version 3:2 —
- Version 3:1 —
Commented-out code in "stress1-server.rkt" as the most expedient way to get new package system build to pass.
- Version 3:0 —
Moving from PLaneT to new package system.
- Version 2:4 —
- Version 2:3 —
Removed file sample-1.rkt from package, to reduce package dependencies. (Suggested by Matt Gushee.)
- Version 2:2 —
Now accommodate SCGI variable names generated by Mellon authentication.
- Version 2:1 —
Now doesn’t barf on headers like proxy-nokeepalive. (Thanks to Erik for bug report and diagnosis.)
- Version 2:0 —
The three main procedures arguments to the cgi procedure now have keywords. What are now the #:startup and #:shutdown arguments are now also optional.
Converted to McFly.
Changed internal-only identifiers from having a % prefix to a %scgi: prefix, to help disambiguate when identifiers appear in error messages in large systems.
Improvement to the internal debugging macro.
- Version 0.6 —
Version 1:5 — 2011-08-22
Small documentation fixes.
- Version 0.5 —
Version 1:4 — 2011-05-16
For closer to backward compatibility with PLT Scheme 4.x, changed references to racket modules to scheme.
- Version 0.4 —
Version 1:3 — 2011-05-16
Added #:reuse-scgi-port? argument to procedure cgi. Added several new CGI environment variable procedures.
The cgi procedure now uses tcp-accept/enable-break rather than tcp-accept.
Added more log-debug.
Added documentation about mod_scgi configuration, troubleshooting,and the keyword arguments to the cgi procedure.
Removed documentation placeholders for end-cgi-request for now.
Various additional quality assurance testing has been done, and more is the works.
- Version 0.3 —
Version 1:2 — 2010-11-14
- Version 0.2 —
Version 1:1 — 2010-10-11
Documentation changes to reflect that it is successfully in use in a real system, and some work remains.
- Version 0.1 —
Version 1:0 — 2010-05-25
Initial release. Preliminary.
Copyright 2010–2013, 2015, 2016 Neil Van Dyke. This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See http://www.gnu.org/licenses/ for details. For other licenses and consulting, please contact the author.