|(require (planet neil/scgi:2:0))|
(require (planet neil/scgi:2)) (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 down for cgi-type ~S..." (cgi-type))))
(define cgi-remote-user (make-cgi-variable-proc 'cgi-remote-user #"REMOTE_USER"))
(cgi-content-type) → string? (cgi-document-root) → string? (cgi-http-cookie) → string? (cgi-http-host) → string? (cgi-http-referer) → string? (cgi-http-user-agent) → string? (cgi-https) → string? (cgi-path-info) → string? (cgi-path-translated) → string? (cgi-query-string) → string? (cgi-remote-addr) → string? (cgi-remote-host) → string? (cgi-remote-user) → string? (cgi-request-method) → string? (cgi-request-uri) → string? (cgi-script-name) → string? (cgi-server-name) → string? (cgi-server-port) → string?
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.
- PLaneT 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 —
PLaneT 1:5 — 2011-08-22
Small documentation fixes.
- Version 0.5 —
PLaneT 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 —
PLaneT 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 —
PLaneT 1:2 — 2010-11-14
- Version 0.2 —
PLaneT 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 —
PLaneT 1:0 — 2010-05-25
Initial release. Preliminary.
Copyright 2010 – 2012 Neil Van Dyke. This program is Free Software; 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.