├── README.md ├── original ├── files │ ├── defaults.css │ ├── node.css │ ├── style.css │ ├── system-menus.css │ ├── system.css │ └── user.css └── spec.html └── spec.md /README.md: -------------------------------------------------------------------------------- 1 | # FastCGI Spec 2 | 3 | Since fastcgi.com is not available anymore, I ([fbbdev](https://github.com/fbbdev)) created this repository and linked website [fast-cgi.github.io](https://fast-cgi.github.io) to host the FastCGI Spec. 4 | 5 | ## Contents 6 | 7 | This repository contains two version of the specification: 8 | 9 | * The original version from fastcgi.com, pulled from the Wayback Machine archive, at [original/spec.html](original/spec.html) 10 | 11 | * A markdown version, manually converted from the original, at [spec.md](spec.md). Text and most formatting in this version is identical to the original, the only exception being the [References](spec.md#9-references) section: there, after the original text, a subsection has been added with live links to updated sources. 12 | 13 | Visit [the website](https://fast-cgi.github.io) to read a nicely formatted version of the spec. 14 | 15 | ## FastCGI Specification copyright 16 | 17 | This is not an official repository nor is it linked in any way to the original fastcgi.com website and FastCGI copyright owners. 18 | 19 | The FastCGI Specification is intellectual property of Open Market Inc. 20 | Copyright © 1996 Open Market, Inc. 245 First Street, Cambridge, MA 02142 U.S.A. 21 | Tel: 617-621-9500 Fax: 617-621-1703 URL: http://www.openmarket.com/ 22 | -------------------------------------------------------------------------------- /original/files/defaults.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /* 7 | FILE ARCHIVED ON 5:31:50 Mar 5, 2016 AND RETRIEVED FROM THE 8 | INTERNET ARCHIVE ON 8:07:38 May 20, 2016. 9 | JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. 10 | 11 | ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. 12 | SECTION 108(a)(3)). 13 | */ 14 | /* $Id: defaults.css,v 1.5 2007/10/02 12:10:40 dries Exp $ */ 15 | 16 | /* 17 | ** HTML elements 18 | */ 19 | fieldset { 20 | margin-bottom: 1em; 21 | padding: .5em; 22 | } 23 | form { 24 | margin: 0; 25 | padding: 0; 26 | } 27 | hr { 28 | height: 1px; 29 | border: 1px solid gray; 30 | } 31 | img { 32 | border: 0; 33 | } 34 | table { 35 | border-collapse: collapse; 36 | } 37 | th { 38 | text-align: left; /* LTR */ 39 | padding-right: 1em; /* LTR */ 40 | border-bottom: 3px solid #ccc; 41 | } 42 | 43 | /* 44 | ** Markup free clearing 45 | ** Details: http://www.positioniseverything.net/easyclearing.html 46 | */ 47 | .clear-block:after { 48 | content: "."; 49 | display: block; 50 | height: 0; 51 | clear: both; 52 | visibility: hidden; 53 | } 54 | 55 | .clear-block { 56 | display: inline-block; 57 | } 58 | 59 | /* Hides from IE-mac \*/ 60 | * html .clear-block { 61 | height: 1%; 62 | } 63 | .clear-block { 64 | display: block; 65 | } 66 | /* End hide from IE-mac */ 67 | -------------------------------------------------------------------------------- /original/files/node.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /* 7 | FILE ARCHIVED ON 7:46:43 Mar 10, 2016 AND RETRIEVED FROM THE 8 | INTERNET ARCHIVE ON 8:07:38 May 20, 2016. 9 | JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. 10 | 11 | ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. 12 | SECTION 108(a)(3)). 13 | */ 14 | /* $Id: node.css,v 1.5 2008/01/25 21:21:44 goba Exp $ */ 15 | 16 | .node-unpublished { 17 | background-color: #fff4f4; 18 | } 19 | .preview .node { 20 | background-color: #ffffea; 21 | } 22 | #node-admin-filter ul { 23 | list-style-type: none; 24 | padding: 0; 25 | margin: 0; 26 | width: 100%; 27 | } 28 | #node-admin-buttons { 29 | float: left; /* LTR */ 30 | margin-left: 0.5em; /* LTR */ 31 | clear: right; /* LTR */ 32 | } 33 | td.revision-current { 34 | background: #ffc; 35 | } 36 | .node-form .form-text { 37 | display: block; 38 | width: 95%; 39 | } 40 | .node-form .container-inline .form-text { 41 | display: inline; 42 | width: auto; 43 | } 44 | .node-form .standard { 45 | clear: both; 46 | } 47 | .node-form textarea { 48 | display: block; 49 | width: 95%; 50 | } 51 | .node-form .attachments fieldset { 52 | float: none; 53 | display: block; 54 | } 55 | .terms-inline { 56 | display: inline; 57 | } 58 | -------------------------------------------------------------------------------- /original/files/style.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /* 7 | FILE ARCHIVED ON 11:37:56 Mar 5, 2016 AND RETRIEVED FROM THE 8 | INTERNET ARCHIVE ON 8:07:39 May 20, 2016. 9 | JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. 10 | 11 | ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. 12 | SECTION 108(a)(3)). 13 | */ 14 | body { 15 | padding:0px; 16 | margin:0px; 17 | background:url(/web/20160305113756/http://www.fastcgi.com/drupal/sites/all/themes/FastCGI/images/bg.jpg) top left repeat-x; 18 | font-family:Verdana, Arial, Helvetica, sans-serif; 19 | font-size:100.1% 20 | } 21 | #wrapper { 22 | width:980px; 23 | margin:20px auto; 24 | background:#CCCCCC; 25 | } 26 | #logo { 27 | background:url(/web/20160305113756/http://www.fastcgi.com/drupal/sites/all/themes/FastCGI/images/logo.jpg) no-repeat top left; 28 | height:200px; 29 | 30 | } 31 | #footer { 32 | background:url(/web/20160305113756/http://www.fastcgi.com/drupal/sites/all/themes/FastCGI/images/footer.jpg) no-repeat top left; 33 | height:18px; 34 | text-align:center; 35 | font-size:60%; 36 | padding:42px 0 0 0; 37 | } 38 | #footer a:link, #footer a:visited, #footer a:hover { 39 | color:#000; 40 | text-decoration:none; 41 | } 42 | #content { 43 | background:url(/web/20160305113756/http://www.fastcgi.com/drupal/sites/all/themes/FastCGI/images/content.jpg) repeat-y top left; 44 | padding:10px 40px; 45 | font-size:80%; 46 | } 47 | #heading { 48 | background:url(/web/20160305113756/http://www.fastcgi.com/drupal/sites/all/themes/FastCGI/images/heading.jpg) no-repeat top left; 49 | height:40px; 50 | margin:0; 51 | padding:20px 0 0 50px; 52 | color:#fff; 53 | font-size:120%; 54 | } 55 | #nav { 56 | background:url(/web/20160305113756/http://www.fastcgi.com/drupal/sites/all/themes/FastCGI/images/navbar.jpg) no-repeat top left; 57 | height:40px; 58 | font-size:80%; 59 | } 60 | #nav ul { 61 | list-style-type: none; 62 | float:right; 63 | margin:0 10px 0 0; 64 | } 65 | #nav ul li { 66 | display:inline; 67 | } 68 | #nav ul li a{ 69 | font-size:100%; 70 | padding:12px 14px 0 14px; 71 | margin:0 -1px 0 0; 72 | float: left; 73 | text-align: center; 74 | height:28px; 75 | } 76 | #nav ul li a:link, #nav ul li a:visited { 77 | color:#fff; 78 | text-decoration:none; 79 | } 80 | #nav ul li a:hover { 81 | background:url(/web/20160305113756/http://www.fastcgi.com/drupal/sites/all/themes/FastCGI/images/buttonhov.jpg) repeat-x top left; 82 | color:#000; 83 | } 84 | #content ul { 85 | margin:0px 30px; 86 | padding:0; 87 | list-style:url(/web/20160305113756/http://www.fastcgi.com/drupal/sites/all/themes/FastCGI/images/bullet.jpg); 88 | } 89 | .messages { 90 | margin:20px 0 0 0; 91 | } 92 | 93 | #content ul li { 94 | margin:6px 2px; 95 | } 96 | a:link, a:visited { 97 | color:#f60; 98 | } 99 | a:hover { 100 | color:#000; 101 | } 102 | 103 | #bottombar { 104 | background:#f95 url(/web/20160305113756/http://www.fastcgi.com/drupal/sites/all/themes/FastCGI/images/bottombar.jpg) repeat-x top left; 105 | padding:10px 20px; 106 | border-bottom:1px #000 solid; 107 | } 108 | #header-region { 109 | background:#f95 url(/web/20160305113756/http://www.fastcgi.com/drupal/sites/all/themes/FastCGI/images/topbar.jpg) repeat-x bottom left; 110 | padding:10px 20px; 111 | 112 | } 113 | #bottombar a:link, #bottombar a:visited, #header-region a:link, #header-region a:visited, #sidebar-right a:link, #sidebar-right a:visited, #sidebar-left a:link, #sidebar-left a:visited { 114 | color:#000; 115 | } 116 | 117 | #bottombar .form-item, #header-region .form-item { 118 | width:300px; 119 | 120 | text-align:left; 121 | } 122 | #bottombar .form-item label, #header-region .form-item label{ 123 | padding:5px 0 0 0; 124 | float:left; 125 | width:40%; 126 | } 127 | 128 | #bottombar h2, #header-region h2 { 129 | color:#fff; 130 | font-size:110%; 131 | font-weight:normal; 132 | margin:10px 0 0 0; 133 | padding:0; 134 | } 135 | .item-list ul { 136 | 137 | 138 | text-align:left; 139 | } 140 | #edit-submit { 141 | 142 | text-align:center; 143 | } 144 | #bottombar .content, #header-region .content { 145 | width:500px; 146 | font-size:80%; 147 | } 148 | 149 | ul.secondary li a:link, ul.secondary li a:visited { 150 | border:1px solid #000; 151 | padding:2px 10px; 152 | background:#fff; 153 | color:#000; 154 | } 155 | ul.secondary li a:hover { 156 | 157 | background:#f60; 158 | color:#fff; 159 | } 160 | ul.secondary li.active a { 161 | 162 | background:#f60; 163 | color:#fff; 164 | } 165 | ul.secondary { 166 | border:0px; 167 | 168 | } 169 | 170 | ul.primary li a:link, ul.primary li a:visited { 171 | border:1px solid #000; 172 | padding:2px 10px; 173 | background:#fff; 174 | color:#000; 175 | 176 | 177 | } 178 | ul.primary li a:hover { 179 | 180 | background:#f60; 181 | color:#fff; 182 | } 183 | ul.primary li.active a { 184 | 185 | background:#f60; 186 | color:#fff; 187 | } 188 | ul.primary { 189 | border:0px; 190 | height:30px; 191 | } 192 | #tabs-wrapper{ 193 | margin:0 0 20px 0; 194 | } 195 | 196 | #sidebar-left h2, #sidebar-right h2 { 197 | font-weight:normal; 198 | margin:3px 4px 0 4px; 199 | } 200 | 201 | #sidebar-left, #sidebar-right{ 202 | 203 | -moz-opacity: 0.70; 204 | filter: Alpha(Opacity=70); 205 | font-size:80%; 206 | background:#CCCCCC; 207 | border:#000 solid 1px; 208 | padding:5px; 209 | position:fixed; 210 | bottom:5px; 211 | 212 | } 213 | #sidebar-right { 214 | float:right; 215 | right:5px; 216 | } 217 | #sidebar-left { 218 | float:left; 219 | left:5px; 220 | } 221 | #bread { 222 | text-align:right; 223 | margin:0; 224 | padding:10px 30px 0 0; 225 | font-size:70%; 226 | color:#000 227 | } 228 | #bread a:link, #bread a:visited { 229 | color:#000000; 230 | text-decoration:none; 231 | } -------------------------------------------------------------------------------- /original/files/system-menus.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /* 7 | FILE ARCHIVED ON 7:46:43 Mar 10, 2016 AND RETRIEVED FROM THE 8 | INTERNET ARCHIVE ON 8:07:38 May 20, 2016. 9 | JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. 10 | 11 | ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. 12 | SECTION 108(a)(3)). 13 | */ 14 | /* $Id: system-menus.css,v 1.1 2007/10/05 14:50:25 goba Exp $ */ 15 | 16 | ul.menu { 17 | list-style: none; 18 | border: none; 19 | text-align:left; /* LTR */ 20 | } 21 | ul.menu li { 22 | margin: 0 0 0 0.5em; /* LTR */ 23 | } 24 | li.expanded { 25 | list-style-type: circle; 26 | list-style-image: url(/web/20160310074643/http://www.fastcgi.com/drupal/misc/menu-expanded.png); 27 | padding: 0.2em 0.5em 0 0; /* LTR */ 28 | margin: 0; 29 | } 30 | li.collapsed { 31 | list-style-type: disc; 32 | list-style-image: url(/web/20160310074643/http://www.fastcgi.com/drupal/misc/menu-collapsed.png); /* LTR */ 33 | padding: 0.2em 0.5em 0 0; /* LTR */ 34 | margin: 0; 35 | } 36 | li.leaf { 37 | list-style-type: square; 38 | list-style-image: url(/web/20160310074643/http://www.fastcgi.com/drupal/misc/menu-leaf.png); 39 | padding: 0.2em 0.5em 0 0; /* LTR */ 40 | margin: 0; 41 | } 42 | li a.active { 43 | color: #000; 44 | } 45 | td.menu-disabled { 46 | background: #ccc; 47 | } 48 | ul.links { 49 | margin: 0; 50 | padding: 0; 51 | } 52 | ul.links.inline { 53 | display: inline; 54 | } 55 | ul.links li { 56 | display: inline; 57 | list-style-type: none; 58 | padding: 0 0.5em; 59 | } 60 | .block ul { 61 | margin: 0; 62 | padding: 0 0 0.25em 1em; /* LTR */ 63 | } 64 | -------------------------------------------------------------------------------- /original/files/system.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /* 7 | FILE ARCHIVED ON 7:46:45 Mar 10, 2016 AND RETRIEVED FROM THE 8 | INTERNET ARCHIVE ON 8:07:38 May 20, 2016. 9 | JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. 10 | 11 | ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. 12 | SECTION 108(a)(3)). 13 | */ 14 | /* $Id: system.css,v 1.48 2008/01/09 09:56:39 goba Exp $ */ 15 | 16 | /* 17 | ** HTML elements 18 | */ 19 | body.drag { 20 | cursor: move; 21 | } 22 | th.active img { 23 | display: inline; 24 | } 25 | tr.even, tr.odd { 26 | background-color: #eee; 27 | border-bottom: 1px solid #ccc; 28 | padding: 0.1em 0.6em; 29 | } 30 | tr.drag { 31 | background-color: #fffff0; 32 | } 33 | tr.drag-previous { 34 | background-color: #ffd; 35 | } 36 | td.active { 37 | background-color: #ddd; 38 | } 39 | td.checkbox, th.checkbox { 40 | text-align: center; 41 | } 42 | tbody { 43 | border-top: 1px solid #ccc; 44 | } 45 | tbody th { 46 | border-bottom: 1px solid #ccc; 47 | } 48 | thead th { 49 | text-align: left; /* LTR */ 50 | padding-right: 1em; /* LTR */ 51 | border-bottom: 3px solid #ccc; 52 | } 53 | 54 | /* 55 | ** Other common styles 56 | */ 57 | .breadcrumb { 58 | padding-bottom: .5em 59 | } 60 | div.indentation { 61 | width: 20px; 62 | height: 1.7em; 63 | margin: -0.4em 0.2em -0.4em -0.4em; /* LTR */ 64 | padding: 0.42em 0 0.42em 0.6em; /* LTR */ 65 | float: left; /* LTR */ 66 | } 67 | div.tree-child { 68 | background: url(/web/20160310074645/http://www.fastcgi.com/drupal/misc/tree.png) no-repeat 11px center; /* LTR */ 69 | } 70 | div.tree-child-last { 71 | background: url(/web/20160310074645/http://www.fastcgi.com/drupal/misc/tree-bottom.png) no-repeat 11px center; /* LTR */ 72 | } 73 | div.tree-child-horizontal { 74 | background: url(/web/20160310074645/http://www.fastcgi.com/drupal/misc/tree.png) no-repeat -11px center; 75 | } 76 | .error { 77 | color: #e55; 78 | } 79 | div.error { 80 | border: 1px solid #d77; 81 | } 82 | div.error, tr.error { 83 | background: #fcc; 84 | color: #200; 85 | padding: 2px; 86 | } 87 | .warning { 88 | color: #e09010; 89 | } 90 | div.warning { 91 | border: 1px solid #f0c020; 92 | } 93 | div.warning, tr.warning { 94 | background: #ffd; 95 | color: #220; 96 | padding: 2px; 97 | } 98 | .ok { 99 | color: #008000; 100 | } 101 | div.ok { 102 | border: 1px solid #00aa00; 103 | } 104 | div.ok, tr.ok { 105 | background: #dfd; 106 | color: #020; 107 | padding: 2px; 108 | } 109 | .item-list .icon { 110 | color: #555; 111 | float: right; /* LTR */ 112 | padding-left: 0.25em; /* LTR */ 113 | clear: right; /* LTR */ 114 | } 115 | .item-list .title { 116 | font-weight: bold; 117 | } 118 | .item-list ul { 119 | margin: 0 0 0.75em 0; 120 | padding: 0; 121 | } 122 | .item-list ul li { 123 | margin: 0 0 0.25em 1.5em; /* LTR */ 124 | padding: 0; 125 | list-style: disc; 126 | } 127 | ol.task-list li.active { 128 | font-weight: bold; 129 | } 130 | .form-item { 131 | margin-top: 1em; 132 | margin-bottom: 1em; 133 | } 134 | tr.odd .form-item, tr.even .form-item { 135 | margin-top: 0; 136 | margin-bottom: 0; 137 | white-space: nowrap; 138 | } 139 | tr.merge-down, tr.merge-down td, tr.merge-down th { 140 | border-bottom-width: 0 !important; 141 | } 142 | tr.merge-up, tr.merge-up td, tr.merge-up th { 143 | border-top-width: 0 !important; 144 | } 145 | .form-item input.error, .form-item textarea.error, .form-item select.error { 146 | border: 2px solid red; 147 | } 148 | .form-item .description { 149 | font-size: 0.85em; 150 | } 151 | .form-item label { 152 | display: block; 153 | font-weight: bold; 154 | } 155 | .form-item label.option { 156 | display: inline; 157 | font-weight: normal; 158 | } 159 | .form-checkboxes, .form-radios { 160 | margin: 1em 0; 161 | } 162 | .form-checkboxes .form-item, .form-radios .form-item { 163 | margin-top: 0.4em; 164 | margin-bottom: 0.4em; 165 | } 166 | .marker, .form-required { 167 | color: #f00; 168 | } 169 | .more-link { 170 | text-align: right; /* LTR */ 171 | } 172 | .more-help-link { 173 | font-size: 0.85em; 174 | text-align: right; /* LTR */ 175 | } 176 | .nowrap { 177 | white-space: nowrap; 178 | } 179 | .item-list .pager { 180 | clear: both; 181 | text-align: center; 182 | } 183 | .item-list .pager li { 184 | background-image:none; 185 | display:inline; 186 | list-style-type:none; 187 | padding: 0.5em; 188 | } 189 | .pager-current { 190 | font-weight:bold; 191 | } 192 | .tips { 193 | margin-top: 0; 194 | margin-bottom: 0; 195 | padding-top: 0; 196 | padding-bottom: 0; 197 | font-size: 0.9em; 198 | } 199 | dl.multiselect dd.b, dl.multiselect dd.b .form-item, dl.multiselect dd.b select { 200 | font-family: inherit; 201 | font-size: inherit; 202 | width: 14em; 203 | } 204 | dl.multiselect dd.a, dl.multiselect dd.a .form-item { 205 | width: 8em; 206 | } 207 | dl.multiselect dt, dl.multiselect dd { 208 | float: left; /* LTR */ 209 | line-height: 1.75em; 210 | padding: 0; 211 | margin: 0 1em 0 0; /* LTR */ 212 | } 213 | dl.multiselect .form-item { 214 | height: 1.75em; 215 | margin: 0; 216 | } 217 | 218 | /* 219 | ** Inline items (need to override above) 220 | */ 221 | .container-inline div, .container-inline label { 222 | display: inline; 223 | } 224 | 225 | /* 226 | ** Tab navigation 227 | */ 228 | ul.primary { 229 | border-collapse: collapse; 230 | padding: 0 0 0 1em; /* LTR */ 231 | white-space: nowrap; 232 | list-style: none; 233 | margin: 5px; 234 | height: auto; 235 | line-height: normal; 236 | border-bottom: 1px solid #bbb; 237 | } 238 | ul.primary li { 239 | display: inline; 240 | } 241 | ul.primary li a { 242 | background-color: #ddd; 243 | border-color: #bbb; 244 | border-width: 1px; 245 | border-style: solid solid none solid; 246 | height: auto; 247 | margin-right: 0.5em; /* LTR */ 248 | padding: 0 1em; 249 | text-decoration: none; 250 | } 251 | ul.primary li.active a { 252 | background-color: #fff; 253 | border: 1px solid #bbb; 254 | border-bottom: #fff 1px solid; 255 | } 256 | ul.primary li a:hover { 257 | background-color: #eee; 258 | border-color: #ccc; 259 | border-bottom-color: #eee; 260 | } 261 | ul.secondary { 262 | border-bottom: 1px solid #bbb; 263 | padding: 0.5em 1em; 264 | margin: 5px; 265 | } 266 | ul.secondary li { 267 | display: inline; 268 | padding: 0 1em; 269 | border-right: 1px solid #ccc; /* LTR */ 270 | } 271 | ul.secondary a { 272 | padding: 0; 273 | text-decoration: none; 274 | } 275 | ul.secondary a.active { 276 | border-bottom: 4px solid #999; 277 | } 278 | 279 | /* 280 | ** Autocomplete styles 281 | */ 282 | /* Suggestion list */ 283 | #autocomplete { 284 | position: absolute; 285 | border: 1px solid; 286 | overflow: hidden; 287 | z-index: 100; 288 | } 289 | #autocomplete ul { 290 | margin: 0; 291 | padding: 0; 292 | list-style: none; 293 | } 294 | #autocomplete li { 295 | background: #fff; 296 | color: #000; 297 | white-space: pre; 298 | cursor: default; 299 | } 300 | #autocomplete li.selected { 301 | background: #0072b9; 302 | color: #fff; 303 | } 304 | /* Animated throbber */ 305 | html.js input.form-autocomplete { 306 | background-image: url(/web/20160310074645/http://www.fastcgi.com/drupal/misc/throbber.gif); 307 | background-repeat: no-repeat; 308 | background-position: 100% 2px; /* LTR */ 309 | } 310 | html.js input.throbbing { 311 | background-position: 100% -18px; /* LTR */ 312 | } 313 | 314 | /* 315 | ** Collapsing fieldsets 316 | */ 317 | html.js fieldset.collapsed { 318 | border-bottom-width: 0; 319 | border-left-width: 0; 320 | border-right-width: 0; 321 | margin-bottom: 0; 322 | height: 1em; 323 | } 324 | html.js fieldset.collapsed * { 325 | display: none; 326 | } 327 | html.js fieldset.collapsed legend { 328 | display: block; 329 | } 330 | html.js fieldset.collapsible legend a { 331 | padding-left: 15px; /* LTR */ 332 | background: url(/web/20160310074645/http://www.fastcgi.com/drupal/misc/menu-expanded.png) 5px 75% no-repeat; /* LTR */ 333 | } 334 | html.js fieldset.collapsed legend a { 335 | background-image: url(/web/20160310074645/http://www.fastcgi.com/drupal/misc/menu-collapsed.png); /* LTR */ 336 | background-position: 5px 50%; /* LTR */ 337 | } 338 | /* Note: IE-only fix due to '* html' (breaks Konqueror otherwise). */ 339 | * html.js fieldset.collapsed legend, 340 | * html.js fieldset.collapsed legend *, 341 | * html.js fieldset.collapsed table * { 342 | display: inline; 343 | } 344 | /* For Safari 2 to prevent collapsible fieldsets containing tables from dissapearing due to tableheader.js. */ 345 | html.js fieldset.collapsible { 346 | position: relative; 347 | } 348 | html.js fieldset.collapsible legend a { 349 | display: block; 350 | } 351 | /* Avoid jumping around due to margins collapsing into collapsible fieldset border */ 352 | html.js fieldset.collapsible .fieldset-wrapper { 353 | overflow: auto; 354 | } 355 | 356 | /* 357 | ** Resizable text areas 358 | */ 359 | .resizable-textarea { 360 | width: 95%; 361 | } 362 | .resizable-textarea .grippie { 363 | height: 9px; 364 | overflow: hidden; 365 | background: #eee url(/web/20160310074645/http://www.fastcgi.com/drupal/misc/grippie.png) no-repeat center 2px; 366 | border: 1px solid #ddd; 367 | border-top-width: 0; 368 | cursor: s-resize; 369 | } 370 | html.js .resizable-textarea textarea { 371 | margin-bottom: 0; 372 | width: 100%; 373 | display: block; 374 | } 375 | 376 | /* 377 | ** Table drag and drop. 378 | */ 379 | .draggable a.tabledrag-handle { 380 | cursor: move; 381 | float: left; /* LTR */ 382 | height: 1.7em; 383 | margin: -0.4em 0 -0.4em -0.5em; /* LTR */ 384 | padding: 0.42em 1.5em 0.42em 0.5em; /* LTR */ 385 | text-decoration: none; 386 | } 387 | a.tabledrag-handle:hover { 388 | text-decoration: none; 389 | } 390 | a.tabledrag-handle .handle { 391 | margin-top: 4px; 392 | height: 13px; 393 | width: 13px; 394 | background: url(/web/20160310074645/http://www.fastcgi.com/drupal/misc/draggable.png) no-repeat 0 0; 395 | } 396 | a.tabledrag-handle-hover .handle { 397 | background-position: 0 -20px; 398 | } 399 | 400 | /* 401 | ** Teaser splitter 402 | */ 403 | .joined + .grippie { 404 | height: 5px; 405 | background-position: center 1px; 406 | margin-bottom: -2px; 407 | } 408 | /* Keeps inner content contained in Opera 9. */ 409 | .teaser-checkbox { 410 | padding-top: 1px; 411 | } 412 | div.teaser-button-wrapper { 413 | float: right; /* LTR */ 414 | padding-right: 5%; /* LTR */ 415 | margin: 0; 416 | } 417 | .teaser-checkbox div.form-item { 418 | float: right; /* LTR */ 419 | margin: 0 5% 0 0; /* LTR */ 420 | padding: 0; 421 | } 422 | textarea.teaser { 423 | display: none; 424 | } 425 | html.js .no-js { 426 | display: none; 427 | } 428 | 429 | /* 430 | ** Progressbar styles 431 | */ 432 | .progress { 433 | font-weight: bold; 434 | } 435 | .progress .bar { 436 | background: #fff url(/web/20160310074645/http://www.fastcgi.com/drupal/misc/progress.gif); 437 | border: 1px solid #00375a; 438 | height: 1.5em; 439 | margin: 0 0.2em; 440 | } 441 | .progress .filled { 442 | background: #0072b9; 443 | height: 1em; 444 | border-bottom: 0.5em solid #004a73; 445 | width: 0%; 446 | } 447 | .progress .percentage { 448 | float: right; /* LTR */ 449 | } 450 | .progress-disabled { 451 | float: left; /* LTR */ 452 | } 453 | .ahah-progress { 454 | float: left; /* LTR */ 455 | } 456 | .ahah-progress .throbber { 457 | width: 15px; 458 | height: 15px; 459 | margin: 2px; 460 | background: transparent url(/web/20160310074645/http://www.fastcgi.com/drupal/misc/throbber.gif) no-repeat 0px -18px; 461 | float: left; /* LTR */ 462 | } 463 | tr .ahah-progress .throbber { 464 | margin: 0 2px; 465 | } 466 | .ahah-progress-bar { 467 | width: 16em; 468 | } 469 | 470 | /* 471 | ** Formatting for welcome page 472 | */ 473 | #first-time strong { 474 | display: block; 475 | padding: 1.5em 0 .5em; 476 | } 477 | 478 | /* 479 | ** To be used with tableselect.js 480 | */ 481 | tr.selected td { 482 | background: #ffc; 483 | } 484 | 485 | /* 486 | ** Floating header for tableheader.js 487 | */ 488 | table.sticky-header { 489 | margin-top: 0; 490 | background: #fff; 491 | } 492 | 493 | /* 494 | ** Installation clean URLs 495 | */ 496 | #clean-url.install { 497 | display: none; 498 | } 499 | 500 | /* 501 | ** For anything you want to hide on page load when JS is enabled, so 502 | ** that you can use the JS to control visibility and avoid flicker. 503 | */ 504 | html.js .js-hide { 505 | display: none; 506 | } 507 | 508 | /* 509 | ** Styles for the system modules page (admin/build/modules) 510 | */ 511 | #system-modules div.incompatible { 512 | font-weight: bold; 513 | } 514 | 515 | /* 516 | ** Styles for the system themes page (admin/build/themes) 517 | */ 518 | #system-themes-form div.incompatible { 519 | font-weight: bold; 520 | } 521 | 522 | /* 523 | ** Password strength indicator 524 | */ 525 | span.password-strength { 526 | visibility: hidden; 527 | } 528 | input.password-field { 529 | margin-right: 10px; /* LTR */ 530 | } 531 | div.password-description { 532 | padding: 0 2px; 533 | margin: 4px 0 0 0; 534 | font-size: 0.85em; 535 | max-width: 500px; 536 | } 537 | div.password-description ul { 538 | margin-bottom: 0; 539 | } 540 | .password-parent { 541 | margin: 0 0 0 0; 542 | } 543 | /* 544 | ** Password confirmation checker 545 | */ 546 | input.password-confirm { 547 | margin-right: 10px; /* LTR */ 548 | } 549 | .confirm-parent { 550 | margin: 5px 0 0 0; 551 | } 552 | span.password-confirm { 553 | visibility: hidden; 554 | } 555 | span.password-confirm span { 556 | font-weight: normal; 557 | } 558 | -------------------------------------------------------------------------------- /original/files/user.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /* 7 | FILE ARCHIVED ON 7:46:44 Mar 10, 2016 AND RETRIEVED FROM THE 8 | INTERNET ARCHIVE ON 8:07:39 May 20, 2016. 9 | JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. 10 | 11 | ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. 12 | SECTION 108(a)(3)). 13 | */ 14 | /* $Id: user.css,v 1.7 2007/06/21 04:38:41 unconed Exp $ */ 15 | 16 | #permissions td.module { 17 | font-weight: bold; 18 | } 19 | #permissions td.permission { 20 | padding-left: 1.5em; /* LTR */ 21 | } 22 | #access-rules .access-type, #access-rules .rule-type { 23 | margin-right: 1em; /* LTR */ 24 | float: left; /* LTR */ 25 | } 26 | #access-rules .access-type .form-item, #access-rules .rule-type .form-item { 27 | margin-top: 0; 28 | } 29 | #access-rules .mask { 30 | clear: both; 31 | } 32 | #user-login-form { 33 | text-align: center; 34 | } 35 | #user-admin-filter ul { 36 | list-style-type: none; 37 | padding: 0; 38 | margin: 0; 39 | width: 100%; 40 | } 41 | #user-admin-buttons { 42 | float: left; /* LTR */ 43 | margin-left: 0.5em; /* LTR */ 44 | clear: right; /* LTR */ 45 | } 46 | #user-admin-settings fieldset .description { 47 | font-size: 0.85em; 48 | padding-bottom: .5em; 49 | } 50 | 51 | /* Generated by user.module but used by profile.module: */ 52 | .profile { 53 | clear: both; 54 | margin: 1em 0; 55 | } 56 | .profile .picture { 57 | float: right; /* LTR */ 58 | margin: 0 1em 1em 0; /* LTR */ 59 | } 60 | .profile h3 { 61 | border-bottom: 1px solid #ccc; 62 | } 63 | .profile dl { 64 | margin: 0 0 1.5em 0; 65 | } 66 | .profile dt { 67 | margin: 0 0 0.2em 0; 68 | font-weight: bold; 69 | } 70 | .profile dd { 71 | margin: 0 0 1em 0; 72 | } 73 | -------------------------------------------------------------------------------- /original/spec.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FastCGI Specification | FastCGI - 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 26 |
27 | FastCGI Specification
28 |
29 |
30 | 31 | 32 | 33 | 34 |
35 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> 36 | <!--Copyright (c) 1996 Open Market, Inc. --> 37 | <!--See the file "LICENSE.TERMS" for information on usage and redistribution--> 38 | <!--of this file, and for a DISCLAIMER OF ALL WARRANTIES. --> 39 | 43 | 44 |
45 |

46 | FastCGI Specification 47 |

48 |
49 |
50 | Mark R. Brown
51 | Open Market, Inc.
52 | 53 |

54 | Document Version: 1.0
55 | 29 April 1996
56 |

57 |
58 |

59 |

60 |
61 | 62 | Copyright © 1996 Open Market, Inc. 245 First Street, Cambridge, MA 02142 U.S.A.
63 | Tel: 617-621-9500 Fax: 617-621-1703 URL: http://www.openmarket.com/
64 |
65 | $Id: fcgi-spec.html,v 1.4 2002/02/25 00:42:59 robs Exp $ 66 |
67 |
68 | 188 |

189 |

190 | 191 |
192 |

193 | 1. Introduction 194 |

195 |

196 | FastCGI is an open extension to CGI that provides high performance for all Internet applications without the 197 | penalties of Web server APIs. 198 |

199 |

200 | This specification has narrow goal: to specify, from an application perspective, the interface between a 201 | FastCGI application and a Web server that supports FastCGI. Many Web server features related to FastCGI, e.g. 202 | application management facilities, have nothing to do with the application to Web server interface, and are 203 | not described here. 204 |

205 | 206 |

207 | This specification is for Unix (more precisely, for POSIX systems that support Berkeley Sockets). The bulk of 208 | the specification is a simple communications protocol that is independent of byte ordering and will extend to 209 | other systems. 210 |

211 |

212 | We'll introduce FastCGI by comparing it with conventional Unix implementations of CGI/1.1. FastCGI is 213 | designed to support long-lived application processes, i.e. application servers. That's a major 214 | difference compared with conventional Unix implementations of CGI/1.1, which construct an application process, 215 | use it respond to one request, and have it exit. 216 |

217 |

218 | The initial state of a FastCGI process is more spartan than the initial state of a CGI/1.1 process, because 219 | the FastCGI process doesn't begin life connected to anything. It doesn't have the conventional open 220 | files stdin, stdout, and stderr, and it doesn't receive much information 221 | through environment variables. The key piece of initial state in a FastCGI process is a listening socket, 222 | through which it accepts connections from a Web server. 223 |

224 | 225 |

226 | After a FastCGI process accepts a connection on its listening socket, the process executes a simple protocol 227 | to receive and send data. The protocol serves two purposes. First, the protocol multiplexes a single transport 228 | connection between several independent FastCGI requests. This supports applications that are able to process 229 | concurrent requests using event-driven or multi-threaded programming techniques. Second, within each request 230 | the protocol provides several independent data streams in each direction. This way, for instance, both 231 | stdout and stderr data pass over a single transport connection from the application to the 232 | Web server, rather than requiring separate pipes as with CGI/1.1. 233 |

234 |

235 | A FastCGI application plays one of several well-defined roles. The most familiar is the 236 | Responder role, in which the application receives all the information associated with an HTTP request 237 | and generates an HTTP response; that's the role CGI/1.1 programs play. A second role is Authorizer, 238 | in which the application receives all the information associated with an HTTP request and generates an 239 | authorized/unauthorized decision. A third role is Filter, in which the application receives all the 240 | information associated with an HTTP request, plus an extra stream of data from a file stored on the Web 241 | server, and generates a "filtered" version of the data stream as an HTTP response. The framework is 242 | extensible so that more FastCGI can be defined later. 243 |

244 | 245 |

246 | In the remainder of this specification the terms "FastCGI application," "application 247 | process," or "application server" are abbreviated to "application" whenever that 248 | won't cause confusion. 249 |

250 | 251 |

252 |

253 |

254 | 2. Initial Process State 255 |

256 |

257 | 2.1 Argument list 258 |

259 | 260 |

261 | By default the Web server creates an argument list containing a single element, the name of the application, 262 | taken to be the last component of the executable's path name. The Web server may provide a way to specify 263 | a different application name, or a more elaborate argument list. 264 |

265 |

266 | Note that the file executed by the Web server might be an interpreter file (a text file that starts with the 267 | characters #!), in which case the application's argument list is constructed as described in the 268 | execve manpage. 269 |

270 | 271 |

272 |

273 |

274 | 2.2 File descriptors 275 |

276 |

277 | The Web server leaves a single file descriptor, FCGI_LISTENSOCK_FILENO, open when the application 278 | begins execution. This descriptor refers to a listening socket created by the Web server. 279 |

280 | 281 |

282 | FCGI_LISTENSOCK_FILENO equals STDIN_FILENO. The standard descriptors STDOUT_FILENO 283 | and STDERR_FILENO are closed when the application begins execution. A reliable method for an 284 | application to determine whether it was invoked using CGI or FastCGI is to call 285 | getpeername(FCGI_LISTENSOCK_FILENO), which returns -1 with errno set to ENOTCONN 286 | 287 | for a FastCGI application. 288 |

289 |

290 | The Web server's choice of reliable transport, Unix stream pipes (AF_UNIX) or TCP/IP 291 | (AF_INET), is implicit in the internal state of the FCGI_LISTENSOCK_FILENO socket. 292 |

293 |

294 | 295 |

296 |

297 | 2.3 Environment variables 298 |

299 |

300 | The Web server may use environment variables to pass parameters to the application. This specification defines 301 | one such variable, FCGI_WEB_SERVER_ADDRS; we expect more to be defined as the specification evolves. 302 | The Web server may provide a way to bind other environment variables, such as the PATH variable. 303 |

304 | 305 |

306 |

307 |

308 | 2.4 Other state 309 |

310 |

311 | The Web server may provide a way to specify other components of an application's initial process state, 312 | such as the priority, user ID, group ID, root directory, and working directory of the process. 313 |

314 | 315 |

316 |

317 |

318 | 3. Protocol Basics 319 |

320 |

321 | 3.1 Notation 322 |

323 | 324 |

325 | We use C language notation to define protocol message formats. All structure elements are defined in terms of 326 | the unsigned char type, and are arranged so that an ISO C compiler lays them out in the obvious 327 | manner, with no padding. The first byte defined in the structure is transmitted first, the second byte second, 328 | etc. 329 |

330 |

331 | We use two conventions to abbreviate our definitions. 332 |

333 |

334 | First, when two adjacent structure components are named identically except for the suffixes 335 | "B1" and "B0," it means that the two components may be viewed as a 336 | single number, computed as B1<<8 + B0. The name of this single number is the name of the 337 | components, minus the suffixes. This convention generalizes in an obvious way to handle numbers represented in 338 | more than two bytes. 339 |

340 | 341 |

342 | Second, we extend C structs to allow the form 343 |

344 |
        struct {
 345 |             unsigned char mumbleLengthB1;
 346 |             unsigned char mumbleLengthB0;
 347 |             ... /* other stuff */
 348 |             unsigned char mumbleData[mumbleLength];
 349 |         };
 350 | 
351 |

352 | meaning a structure of varying length, where the length of a component is determined by the values of the 353 | indicated earlier component or components. 354 |

355 |

356 | 357 |

358 |

359 | 3.2 Accepting Transport Connections 360 |

361 |

362 | A FastCGI application calls accept() on the socket referred to by file descriptor 363 | FCGI_LISTENSOCK_FILENO to accept a new transport connection. If the accept() succeeds, and 364 | the FCGI_WEB_SERVER_ADDRS environment variable is bound, the application application immediately 365 | performs the following special processing: 366 |

367 | 368 |

369 |

370 |
    371 |
  • 372 | FCGI_WEB_SERVER_ADDRS: The value is a list of valid IP addresses for the Web server. 373 |

    374 | If FCGI_WEB_SERVER_ADDRS was bound, the application checks the peer IP address of the new 375 | connection for membership in the list. If the check fails (including the possibility that the connection 376 | didn't use TCP/IP transport), the application responds by closing the connection. 377 |

    378 | 379 |

    380 | FCGI_WEB_SERVER_ADDRS is expressed as a comma-separated list of IP addresses. Each IP address 381 | is written as four decimal numbers in the range [0..255] separated by decimal points. So one legal 382 | binding for this variable is FCGI_WEB_SERVER_ADDRS=199.170.183.28,199.170.183.71. 383 |

    384 |
    385 |
    386 |
  • 387 |
388 | 389 |

390 | An application may accept several concurrent transport connections, but it need not do so. 391 |

392 |

393 |

394 |

395 | 3.3 Records 396 |

397 |

398 | 399 | Applications execute requests from a Web server using a simple protocol. Details of the protocol depend upon 400 | the application's role, but roughly speaking the Web server first sends parameters and other data to the 401 | application, then the application sends result data to the Web server, and finally the application sends the 402 | Web server an indication that the request is complete. 403 |

404 |

405 | All data that flows over the transport connection is carried in FastCGI records. FastCGI records 406 | accomplish two things. First, records multiplex the transport connection between several independent FastCGI 407 | requests. This multiplexing supports applications that are able to process concurrent requests using 408 | event-driven or multi-threaded programming techniques. Second, records provide several independent data 409 | streams in each direction within a single request. This way, for instance, both stdout and 410 | stderr data can pass over a single transport connection from the application to the Web server, 411 | rather than requiring separate connections. 412 |

413 | 414 |

415 |

416 |
        typedef struct {
 417 |             unsigned char version;
 418 |             unsigned char type;
 419 |             unsigned char requestIdB1;
 420 |             unsigned char requestIdB0;
 421 |             unsigned char contentLengthB1;
 422 |             unsigned char contentLengthB0;
 423 |             unsigned char paddingLength;
 424 |             unsigned char reserved;
 425 |             unsigned char contentData[contentLength];
 426 |             unsigned char paddingData[paddingLength];
 427 |         } FCGI_Record;
 428 | 
429 |

430 | A FastCGI record consists of a fixed-length prefix followed by a variable number of content and padding bytes. 431 | A record contains seven components: 432 |

433 |

434 |

435 | 436 |
    437 |
  • 438 | version: Identifies the FastCGI protocol version. This specification documents 439 | FCGI_VERSION_1. 440 |

    441 |

    442 |
  • 443 |
  • 444 | type: Identifies the FastCGI record type, i.e. the general function that the record performs. 445 | Specific record types and their functions are detailed in later sections. 446 |

    447 | 448 |

    449 |
  • 450 |
  • 451 | requestId: Identifies the FastCGI request to which the record belongs. 452 |

    453 |

    454 |
  • 455 | 456 |
  • 457 | contentLength: The number of bytes in the contentData component of the record. 458 |

    459 |

    460 |
  • 461 |
  • 462 | paddingLength: The number of bytes in the paddingData component of the record. 463 |

    464 | 465 |

    466 |
  • 467 |
  • 468 | contentData: Between 0 and 65535 bytes of data, interpreted according to the record type. 469 |

    470 |

    471 |
  • 472 |
  • 473 | paddingData: Between 0 and 255 bytes of data, which are ignored.
    474 | 475 |
    476 |
  • 477 |
478 |

479 | We use a relaxed C struct initializer syntax to specify constant FastCGI records. We omit the 480 | version component, ignore padding, and treat requestId as a number. Thus 481 | {FCGI_END_REQUEST, 1, {FCGI_REQUEST_COMPLETE,0}} is a record with type == FCGI_END_REQUEST, 482 | requestId == 1, and contentData == {FCGI_REQUEST_COMPLETE,0}. 483 |

484 | 485 |

486 |

487 |
488 | Padding 489 |
490 |

491 | The protocol allows senders to pad the records they send, and requires receivers to interpret the 492 | paddingLength and skip the paddingData. Padding allows senders to keep data aligned for more 493 | efficient processing. Experience with the X window system protocols shows the performance benefit of such 494 | alignment. 495 |

496 | 497 |

498 | We recommend that records be placed on boundaries that are multiples of eight bytes. The fixed-length portion 499 | of a FCGI_Record is eight bytes. 500 |

501 |

502 |

503 |
504 | Managing Request IDs 505 |
506 | 507 |

508 | The Web server re-uses FastCGI request IDs; the application keeps track of the current state of each request 509 | ID on a given transport connection. A request ID R becomes active when the application receives a 510 | record {FCGI_BEGIN_REQUEST, R, ...} and becomes inactive when the application sends a record 511 | {FCGI_END_REQUEST, R, ...} to the Web server. 512 |

513 |

514 | While a request ID R is inactive, the application ignores records with requestId == R, 515 | except for FCGI_BEGIN_REQUEST records as just described. 516 |

517 | 518 |

519 | The Web server attempts to keep FastCGI request IDs small. That way the application can keep track of request 520 | ID states using a short array rather than a long array or a hash table. An application also has the option of 521 | accepting only one request at a time. In this case the application simply checks incoming requestId 522 | values against the current request ID. 523 |

524 |

525 |

526 |
527 | Types of Record Types 528 |
529 | 530 |

531 | There are two useful ways of classifying FastCGI record types. 532 |

533 |

534 | The first distinction is between management records and application records. A management record 535 | contains information that is not specific to any Web server request, such as information about the protocol 536 | capabilities of the application. An application record contains information about a particular request, 537 | identified by the requestId component. 538 |

539 | 540 |

541 | Management records have a requestId value of zero, also called the null request ID. 542 | Application records have a nonzero requestId. 543 |

544 |

545 | The second distinction is between discrete and stream records. A discrete record contains a 546 | meaningful unit of data all by itself. A stream record is part of a stream, i.e. a series of zero or 547 | more non-empty records (length != 0) of the stream type, followed by an empty record (length == 548 | 0) of the stream type. The contentData components of a stream's records, when concatenated, 549 | form a byte sequence; this byte sequence is the value of the stream. Therefore the value of a stream is 550 | independent of how many records it contains or how its bytes are divided among the non-empty records. 551 |

552 | 553 |

554 | These two classifications are independent. Among the record types defined in this version of the FastCGI 555 | protocol, all management record types are also discrete record types, and nearly all application record types 556 | are stream record types. But three application record types are discrete, and nothing prevents defining a 557 | management record type that's a stream in some later version of the protocol. 558 |

559 |

560 |

561 |

562 | 3.4 Name-Value Pairs 563 |

564 | 565 |

566 | In many of their roles, FastCGI applications need to read and write varying numbers of variable-length values. 567 | So it is useful to adopt a standard format for encoding a name-value pair. 568 |

569 |

570 | FastCGI transmits a name-value pair as the length of the name, followed by the length of the value, followed 571 | by the name, followed by the value. Lengths of 127 bytes and less can be encoded in one byte, while longer 572 | lengths are always encoded in four bytes: 573 |

574 |

575 |

576 |
        typedef struct {
 577 |             unsigned char nameLengthB0;  /* nameLengthB0  >> 7 == 0 */
 578 |             unsigned char valueLengthB0; /* valueLengthB0 >> 7 == 0 */
 579 |             unsigned char nameData[nameLength];
 580 |             unsigned char valueData[valueLength];
 581 |         } FCGI_NameValuePair11;
 582 | 
 583 |         typedef struct {
 584 |             unsigned char nameLengthB0;  /* nameLengthB0  >> 7 == 0 */
 585 |             unsigned char valueLengthB3; /* valueLengthB3 >> 7 == 1 */
 586 |             unsigned char valueLengthB2;
 587 |             unsigned char valueLengthB1;
 588 |             unsigned char valueLengthB0;
 589 |             unsigned char nameData[nameLength];
 590 |             unsigned char valueData[valueLength
 591 |                     ((B3 & 0x7f) << 24) + (B2 << 16) + (B1 << 8) + B0];
 592 |         } FCGI_NameValuePair14;
 593 | 
 594 |         typedef struct {
 595 |             unsigned char nameLengthB3;  /* nameLengthB3  >> 7 == 1 */
 596 |             unsigned char nameLengthB2;
 597 |             unsigned char nameLengthB1;
 598 |             unsigned char nameLengthB0;
 599 |             unsigned char valueLengthB0; /* valueLengthB0 >> 7 == 0 */
 600 |             unsigned char nameData[nameLength
 601 |                     ((B3 & 0x7f) << 24) + (B2 << 16) + (B1 << 8) + B0];
 602 |             unsigned char valueData[valueLength];
 603 |         } FCGI_NameValuePair41;
 604 | 
 605 |         typedef struct {
 606 |             unsigned char nameLengthB3;  /* nameLengthB3  >> 7 == 1 */
 607 |             unsigned char nameLengthB2;
 608 |             unsigned char nameLengthB1;
 609 |             unsigned char nameLengthB0;
 610 |             unsigned char valueLengthB3; /* valueLengthB3 >> 7 == 1 */
 611 |             unsigned char valueLengthB2;
 612 |             unsigned char valueLengthB1;
 613 |             unsigned char valueLengthB0;
 614 |             unsigned char nameData[nameLength
 615 |                     ((B3 & 0x7f) << 24) + (B2 << 16) + (B1 << 8) + B0];
 616 |             unsigned char valueData[valueLength
 617 |                     ((B3 & 0x7f) << 24) + (B2 << 16) + (B1 << 8) + B0];
 618 |         } FCGI_NameValuePair44;
 619 | 
 620 | 
621 |

622 | The high-order bit of the first byte of a length indicates the length's encoding. A high-order zero 623 | implies a one-byte encoding, a one a four-byte encoding. 624 |

625 |

626 | This name-value pair format allows the sender to transmit binary values without additional encoding, and 627 | enables the receiver to allocate the correct amount of storage immediately even for large values. 628 |

629 |

630 |

631 |

632 | 633 | 3.5 Closing Transport Connections 634 |

635 |

636 | The Web server controls the lifetime of transport connections. The Web server can close a connection when no 637 | requests are active. Or the Web server can delegate close authority to the application (see 638 | FCGI_BEGIN_REQUEST). In this case the application closes the connection at the end of a specified 639 | request. 640 |

641 |

642 | This flexibility accommodates a variety of application styles. Simple applications will process one request at 643 | a time and accept a new transport connection for each request. More complex applications will process 644 | concurrent requests, over one or multiple transport connections, and will keep transport connections open for 645 | long periods of time. 646 |

647 | 648 |

649 | A simple application gets a significant performance boost by closing the transport connection when it has 650 | finished writing its response. The Web server needs to control the connection lifetime for long-lived 651 | connections. 652 |

653 |

654 | When an application closes a connection or finds that a connection has closed, the application initiates a new 655 | connection. 656 |

657 |

658 |

659 |

660 | 4. Management Record Types 661 | 662 |

663 |

664 | 4.1 FCGI_GET_VALUES, FCGI_GET_VALUES_RESULT 665 |

666 |

667 | The Web server can query specific variables within the application. The server will typically perform a query 668 | on application startup in order to to automate certain aspects of system configuration. 669 |

670 |

671 | 672 | The application receives a query as a record {FCGI_GET_VALUES, 0, ...}. The contentData 673 | portion of a FCGI_GET_VALUES record contains a sequence of name-value pairs with empty values. 674 |

675 |

676 | The application responds by sending a record {FCGI_GET_VALUES_RESULT, 0, ...} with the values 677 | supplied. If the application doesn't understand a variable name that was included in the query, it omits 678 | that name from the response. 679 |

680 | 681 |

682 | FCGI_GET_VALUES is designed to allow an open-ended set of variables. The initial set provides 683 | information to help the server perform application and connection management: 684 |

685 |

686 |

687 |
    688 |
  • 689 | FCGI_MAX_CONNS: The maximum number of concurrent transport connections this application will 690 | accept, e.g. "1" or "10". 691 |

    692 | 693 |

    694 |
  • 695 |
  • 696 | FCGI_MAX_REQS: The maximum number of concurrent requests this application will accept, e.g. 697 | "1" or "50". 698 |

    699 |

    700 | 701 |
  • 702 |
  • 703 | FCGI_MPXS_CONNS: "0" if this application does not multiplex connections (i.e. 704 | handle concurrent requests over each connection), "1" otherwise.
    705 |
    706 |
  • 707 | 708 |
709 |

710 | An application may receive a FCGI_GET_VALUES record at any time. The application's response 711 | should not involve the application proper but only the FastCGI library. 712 |

713 |

714 |

715 |

716 | 717 | 4.2 FCGI_UNKNOWN_TYPE 718 |

719 |

720 | The set of management record types is likely to grow in future versions of this protocol. To provide for this 721 | evolution, the protocol includes the FCGI_UNKNOWN_TYPE management record. When an application 722 | receives a management record whose type T it does not understand, the application responds with 723 | {FCGI_UNKNOWN_TYPE, 0, {T}}. 724 |

725 | 726 |

727 | The contentData component of a FCGI_UNKNOWN_TYPE record has the form: 728 |

729 |
        typedef struct {
 730 |             unsigned char type;    
 731 |             unsigned char reserved[7];
 732 |         } FCGI_UnknownTypeBody;
 733 | 
734 |

735 | 736 | The type component is the type of the unrecognized management record. 737 |

738 |

739 |

740 |

741 | 5. Application Record Types 742 |

743 | 744 |

745 | 5.1 FCGI_BEGIN_REQUEST 746 |

747 |

748 | The Web server sends a FCGI_BEGIN_REQUEST record to start a request. 749 |

750 |

751 | 752 | The contentData component of a FCGI_BEGIN_REQUEST record has the form: 753 |

754 |
        typedef struct {
 755 |             unsigned char roleB1;
 756 |             unsigned char roleB0;
 757 |             unsigned char flags;
 758 |             unsigned char reserved[5];
 759 |         } FCGI_BeginRequestBody;
 760 | 
761 |

762 | The role component sets the role the Web server expects the application to play. The 763 | currently-defined roles are: 764 |

765 | 766 |

767 |

768 |
    769 |
  • 770 | FCGI_RESPONDER 771 |
  • 772 |
  • 773 | FCGI_AUTHORIZER 774 | 775 |
  • 776 |
  • 777 | FCGI_FILTER 778 |
  • 779 |
780 |

781 | Roles are described in more detail in Section 6 below. 782 |

783 | 784 |

785 | The flags component contains a bit that controls connection shutdown: 786 |

787 |

788 |

789 |
    790 |
  • 791 | flags & FCGI_KEEP_CONN: If zero, the application closes the connection after responding to 792 | this request. If not zero, the application does not close the connection after responding to this request; 793 | the Web server retains responsibility for the connection.
    794 | 795 |
    796 |
  • 797 |
798 |

799 | 5.2 Name-Value Pair Stream: FCGI_PARAMS 800 |

801 | FCGI_PARAMS 802 | 803 |

804 | is a stream record type used in sending name-value pairs from the Web server to the application. The 805 | name-value pairs are sent down the stream one after the other, in no specified order. 806 |

807 |

808 |

809 |

810 | 5.3 Byte Streams: FCGI_STDIN, FCGI_DATA, FCGI_STDOUT, 811 | FCGI_STDERR 812 | 813 |

814 | FCGI_STDIN 815 |

816 | is a stream record type used in sending arbitrary data from the Web server to the application. 817 | FCGI_DATA is a second stream record type used to send additional data to the application. 818 |

819 |

820 | FCGI_STDOUT and FCGI_STDERR are stream record types for sending arbitrary data and error 821 | data respectively from the application to the Web server. 822 |

823 | 824 |

825 |

826 |

827 | 5.4 FCGI_ABORT_REQUEST 828 |

829 |

830 | The Web server sends a FCGI_ABORT_REQUEST record to abort a request. After receiving 831 | {FCGI_ABORT_REQUEST, R}, the application responds as soon as possible with {FCGI_END_REQUEST, R, 832 | {FCGI_REQUEST_COMPLETE, appStatus}}. This is truly a response from the application, not a low-level 833 | acknowledgement from the FastCGI library. 834 |

835 | 836 |

837 | A Web server aborts a FastCGI request when an HTTP client closes its transport connection while the FastCGI 838 | request is running on behalf of that client. The situation may seem unlikely; most FastCGI requests will have 839 | short response times, with the Web server providing output buffering if the client is slow. But the FastCGI 840 | application may be delayed communicating with another system, or performing a server push. 841 |

842 |

843 | When a Web server is not multiplexing requests over a transport connection, the Web server can abort a request 844 | by closing the request's transport connection. But with multiplexed requests, closing the transport 845 | connection has the unfortunate effect of aborting all the requests on the connection. 846 |

847 |

848 |

849 | 850 |

851 | 5.5 FCGI_END_REQUEST 852 |

853 |

854 | The application sends a FCGI_END_REQUEST record to terminate a request, either because the 855 | application has processed the request or because the application has rejected the request. 856 |

857 |

858 | 859 | The contentData component of a FCGI_END_REQUEST record has the form: 860 |

861 |
        typedef struct {
 862 |             unsigned char appStatusB3;
 863 |             unsigned char appStatusB2;
 864 |             unsigned char appStatusB1;
 865 |             unsigned char appStatusB0;
 866 |             unsigned char protocolStatus;
 867 |             unsigned char reserved[3];
 868 |         } FCGI_EndRequestBody;
 869 | 
870 |

871 | The appStatus component is an application-level status code. Each role documents its usage of 872 | appStatus. 873 |

874 | 875 |

876 | The protocolStatus component is a protocol-level status code; the possible protocolStatus 877 | values are: 878 |

879 |

880 |

881 |
    882 | 883 |
  • 884 | FCGI_REQUEST_COMPLETE: normal end of request. 885 |

    886 |

    887 |
  • 888 |
  • 889 | FCGI_CANT_MPX_CONN: rejecting a new request. This happens when a Web server sends concurrent 890 | requests over one connection to an application that is designed to process one request at a time per 891 | connection. 892 |

    893 |

    894 | 895 |
  • 896 |
  • 897 | FCGI_OVERLOADED: rejecting a new request. This happens when the application runs out of some 898 | resource, e.g. database connections. 899 |

    900 |

    901 |
  • 902 |
  • 903 | FCGI_UNKNOWN_ROLE: rejecting a new request. This happens when the Web server has specified a role 904 | that is unknown to the application.
    905 | 906 |
    907 |
  • 908 |
909 |

910 | 6. Roles 911 |

912 |

913 | 6.1 Role Protocols 914 | 915 |

916 |

917 | Role protocols only include records with application record types. They transfer essentially all data using 918 | streams. 919 |

920 |

921 | To make the protocols reliable and to simplify application programming, role protocols are designed to use 922 | nearly sequential marshalling. In a protocol with strictly sequential marshalling, the application 923 | receives its first input, then its second, etc. until it has received them all. Similarly, the application 924 | sends its first output, then its second, etc. until it has sent them all. Inputs are not interleaved with each 925 | other, and outputs are not interleaved with each other. 926 |

927 |

928 | The sequential marshalling rule is too restrictive for some FastCGI roles, because CGI programs can write to 929 | both stdout and stderr without timing restrictions. So role protocols that use both 930 | FCGI_STDOUT and FCGI_STDERR allow these two streams to be interleaved. 931 |

932 | 933 |

934 | All role protocols use the FCGI_STDERR stream just the way stderr is used in conventional 935 | applications programming: to report application-level errors in an intelligible way. Use of the 936 | FCGI_STDERR stream is always optional. If an application has no errors to report, it sends either no 937 | FCGI_STDERR records or one zero-length FCGI_STDERR record. 938 |

939 | 940 |

941 | When a role protocol calls for transmitting a stream other than FCGI_STDERR, at least one record of 942 | the stream type is always transmitted, even if the stream is empty. 943 |

944 |

945 | Again in the interests of reliable protocols and simplified application programming, role protocols are 946 | designed to be nearly request-response. In a truly request-response protocol, the application receives 947 | all of its input records before sending its first output record. Request-response protocols don't allow 948 | pipelining. 949 |

950 |

951 | 952 | The request-response rule is too restrictive for some FastCGI roles; after all, CGI programs aren't 953 | restricted to read all of stdin before starting to write stdout. So some role protocols 954 | allow that specific possibility. First the application receives all of its inputs except for a final stream 955 | input. As the application begins to receive the final stream input, it can begin writing its output. 956 |

957 |

958 | When a role protocol uses FCGI_PARAMS to transmit textual values, such as the values that CGI 959 | programs obtain from environment variables, the length of the value does not include the terminating null 960 | byte, and the value itself does not include a null byte. An application that needs to provide 961 | environ(7) format name-value pairs must insert an equal sign between the name and value and append a 962 | null byte after the value. 963 |

964 | 965 |

966 | Role protocols do not support the non-parsed header feature of CGI. FastCGI applications set response status 967 | using the Status and Location CGI headers. 968 |

969 |

970 |

971 |

972 | 973 | 6.2 Responder 974 |

975 |

976 | A Responder FastCGI application has the same purpose as a CGI/1.1 program: It receives all the information 977 | associated with an HTTP request and generates an HTTP response. 978 |

979 |

980 | It suffices to explain how each element of CGI/1.1 is emulated by a Responder: 981 |

982 |
983 | 984 |
985 |
    986 |
  • 987 | The Responder application receives CGI/1.1 environment variables from the Web server over 988 | FCGI_PARAMS. 989 |

    990 |

    991 |
  • 992 |
  • 993 | 994 | Next the Responder application receives CGI/1.1 stdin data from the Web server over 995 | FCGI_STDIN. The application receives at most CONTENT_LENGTH bytes from this stream before 996 | receiving the end-of-stream indication. (The application receives less than CONTENT_LENGTH bytes 997 | only if the HTTP client fails to provide them, e.g. because the client crashed.) 998 |

    999 |

    1000 |
  • 1001 | 1002 |
  • 1003 | The Responder application sends CGI/1.1 stdout data to the Web server over FCGI_STDOUT, 1004 | and CGI/1.1 stderr data over FCGI_STDERR. The application sends these concurrently, not 1005 | one after the other. The application must wait to finish reading FCGI_PARAMS before it begins 1006 | writing FCGI_STDOUT and FCGI_STDERR, but it needn't finish reading from 1007 | FCGI_STDIN before it begins writing these two streams. 1008 |

    1009 | 1010 |

    1011 |
  • 1012 |
  • 1013 | After sending all its stdout and stderr data, the Responder application sends a 1014 | FCGI_END_REQUEST record. The application sets the protocolStatus component to 1015 | FCGI_REQUEST_COMPLETE and the appStatus component to the status code that the CGI program 1016 | would have returned via the exit system call.
    1017 | 1018 |
    1019 |
  • 1020 |
1021 |

1022 | A Responder performing an update, e.g. implementing a POST method, should compare the number of bytes 1023 | received on FCGI_STDIN with CONTENT_LENGTH and abort the update if the two numbers are not 1024 | equal. 1025 |

1026 | 1027 |

1028 |

1029 |

1030 | 6.3 Authorizer 1031 |

1032 |

1033 | An Authorizer FastCGI application receives all the information associated with an HTTP request and generates 1034 | an authorized/unauthorized decision. In case of an authorized decision the Authorizer can also associate 1035 | name-value pairs with the HTTP request; when giving an unauthorized decision the Authorizer sends a complete 1036 | response to the HTTP client. 1037 |

1038 |

1039 | 1040 | Since CGI/1.1 defines a perfectly good way to represent the information associated with an HTTP request, 1041 | Authorizers use the same representation: 1042 |

1043 |

1044 |

1045 |
    1046 |
  • 1047 | The Authorizer application receives HTTP request information from the Web server on the 1048 | FCGI_PARAMS stream, in the same format as a Responder. The Web server does not send 1049 | CONTENT_LENGTH, PATH_INFO, PATH_TRANSLATED, and SCRIPT_NAME headers. 1050 |

    1051 | 1052 |

    1053 |
  • 1054 |
  • 1055 | The Authorizer application sends stdout and stderr data in the same manner as a 1056 | Responder. The CGI/1.1 response status specifies the disposition of the request. If the application sends 1057 | status 200 (OK), the Web server allows access. Depending upon its configuration the Web server may proceed 1058 | with other access checks, including requests to other Authorizers. 1059 |

    1060 | An Authorizer application's 200 response may include headers whose names are prefixed with 1061 | Variable-. These headers communicate name-value pairs from the application to the Web server. 1062 | For instance, the response header 1063 |

    1064 | 1065 |
            Variable-AUTH_METHOD: database lookup
    1066 | 
    1067 | transmits the value "database lookup" with name AUTH-METHOD. The server 1068 | associates such name-value pairs with the HTTP request and includes them in subsequent CGI or FastCGI 1069 | requests performed in processing the HTTP request. When the application gives a 200 response, the server 1070 | ignores response headers whose names aren't prefixed with Variable- prefix, and ignores any 1071 | response content. 1072 |

    1073 | For Authorizer response status values other than "200" (OK), the Web server denies access and 1074 | sends the response status, headers, and content back to the HTTP client. 1075 |

    1076 | 1077 |
    1078 |
    1079 |
  • 1080 |
1081 |

1082 | 6.4 Filter 1083 |

1084 |

1085 | 1086 | A Filter FastCGI application receives all the information associated with an HTTP request, plus an extra 1087 | stream of data from a file stored on the Web server, and generates a "filtered" version of the data 1088 | stream as an HTTP response. 1089 |

1090 |

1091 | A Filter is similar in functionality to a Responder that takes a data file as a parameter. The difference is 1092 | that with a Filter, both the data file and the Filter itself can be access controlled using the Web 1093 | server's access control mechanisms, while a Responder that takes the name of a data file as a parameter 1094 | must perform its own access control checks on the data file. 1095 |

1096 |

1097 | The steps taken by a Filter are similar to those of a Responder. The server presents the Filter with 1098 | environment variables first, then standard input (normally form POST data), finally the data file 1099 | input: 1100 |

1101 | 1102 |
1103 |
1104 |
    1105 |
  • 1106 | Like a Responder, the Filter application receives name-value pairs from the Web server over 1107 | FCGI_PARAMS. Filter applications receive two Filter-specific variables: 1108 | FCGI_DATA_LAST_MOD and FCGI_DATA_LENGTH. 1109 |

    1110 | 1111 |

    1112 |
  • 1113 |
  • 1114 | Next the Filter application receives CGI/1.1 stdin data from the Web server over 1115 | FCGI_STDIN. The application receives at most CONTENT_LENGTH bytes from this stream before 1116 | receiving the end-of-stream indication. (The application receives less than CONTENT_LENGTH bytes 1117 | only if the HTTP client fails to provide them, e.g. because the client crashed.) 1118 |

    1119 | 1120 |

    1121 |
  • 1122 |
  • 1123 | Next the Filter application receives the file data from the Web server over FCGI_DATA. This 1124 | file's last modification time (expressed as an integer number of seconds since the epoch January 1, 1125 | 1970 UTC) is FCGI_DATA_LAST_MOD; the application may consult this variable and respond from a 1126 | cache without reading the file data. The application reads at most FCGI_DATA_LENGTH bytes from 1127 | this stream before receiving the end-of-stream indication. 1128 |

    1129 | 1130 |

    1131 |
  • 1132 |
  • 1133 | The Filter application sends CGI/1.1 stdout data to the Web server over FCGI_STDOUT, and 1134 | CGI/1.1 stderr data over FCGI_STDERR. The application sends these concurrently, not one 1135 | after the other. The application must wait to finish reading FCGI_STDIN before it begins writing 1136 | FCGI_STDOUT and FCGI_STDERR, but it needn't finish reading from FCGI_DATA 1137 | 1138 | before it begins writing these two streams. 1139 |

    1140 |

    1141 |
  • 1142 |
  • 1143 | After sending all its stdout and stderr data, the application sends a 1144 | FCGI_END_REQUEST record. The application sets the protocolStatus component to 1145 | FCGI_REQUEST_COMPLETE and the appStatus component to the status code that a similar CGI 1146 | program would have returned via the exit system call.
    1147 | 1148 |
    1149 |
  • 1150 |
1151 |

1152 | A Filter should compare the number of bytes received on FCGI_STDIN with CONTENT_LENGTH and 1153 | on FCGI_DATA with FCGI_DATA_LENGTH. If the numbers don't match and the Filter is a 1154 | query, the Filter response should provide an indication that data is missing. If the numbers don't match 1155 | and the Filter is an update, the Filter should abort the update. 1156 |

1157 | 1158 |

1159 |

1160 |

1161 | 7. Errors 1162 |

1163 |

1164 | A FastCGI application exits with zero status to indicate that it terminated on purpose, e.g. in order to 1165 | perform a crude form of garbage collection. A FastCGI application that exits with nonzero status is assumed to 1166 | have crashed. How a Web server or other application manager responds to applications that exit with zero or 1167 | nonzero status is outside the scope of this specification. 1168 |

1169 |

1170 | 1171 | A Web server can request that a FastCGI application exit by sending it SIGTERM. If the application 1172 | ignores SIGTERM the Web server can resort to SIGKILL. 1173 |

1174 |

1175 | FastCGI applications report application-level errors with the FCGI_STDERR stream and the 1176 | appStatus component of the FCGI_END_REQUEST record. In many cases an error will be reported 1177 | directly to the user via the FCGI_STDOUT stream. 1178 |

1179 | 1180 |

1181 | On Unix, applications report lower-level errors, including FastCGI protocol errors and syntax errors in 1182 | FastCGI environment variables, to syslog. Depending upon the severity of the error, the application 1183 | may either continue or exit with nonzero status. 1184 |

1185 |

1186 |

1187 |

1188 | 8. Types and Constants 1189 |

1190 | 1191 |
/*
1192 |  * Listening socket file number
1193 |  */
1194 | #define FCGI_LISTENSOCK_FILENO 0
1195 | 
1196 | typedef struct {
1197 |     unsigned char version;
1198 |     unsigned char type;
1199 |     unsigned char requestIdB1;
1200 |     unsigned char requestIdB0;
1201 |     unsigned char contentLengthB1;
1202 |     unsigned char contentLengthB0;
1203 |     unsigned char paddingLength;
1204 |     unsigned char reserved;
1205 | } FCGI_Header;
1206 | 
1207 | /*
1208 |  * Number of bytes in a FCGI_Header.  Future versions of the protocol
1209 |  * will not reduce this number.
1210 |  */
1211 | #define FCGI_HEADER_LEN  8
1212 | 
1213 | /*
1214 |  * Value for version component of FCGI_Header
1215 |  */
1216 | #define FCGI_VERSION_1           1
1217 | 
1218 | /*
1219 |  * Values for type component of FCGI_Header
1220 |  */
1221 | #define FCGI_BEGIN_REQUEST       1
1222 | #define FCGI_ABORT_REQUEST       2
1223 | #define FCGI_END_REQUEST         3
1224 | #define FCGI_PARAMS              4
1225 | #define FCGI_STDIN               5
1226 | #define FCGI_STDOUT              6
1227 | #define FCGI_STDERR              7
1228 | #define FCGI_DATA                8
1229 | #define FCGI_GET_VALUES          9
1230 | #define FCGI_GET_VALUES_RESULT  10
1231 | #define FCGI_UNKNOWN_TYPE       11
1232 | #define FCGI_MAXTYPE (FCGI_UNKNOWN_TYPE)
1233 | 
1234 | /*
1235 |  * Value for requestId component of FCGI_Header
1236 |  */
1237 | #define FCGI_NULL_REQUEST_ID     0
1238 | 
1239 | typedef struct {
1240 |     unsigned char roleB1;
1241 |     unsigned char roleB0;
1242 |     unsigned char flags;
1243 |     unsigned char reserved[5];
1244 | } FCGI_BeginRequestBody;
1245 | 
1246 | typedef struct {
1247 |     FCGI_Header header;
1248 |     FCGI_BeginRequestBody body;
1249 | } FCGI_BeginRequestRecord;
1250 | 
1251 | /*
1252 |  * Mask for flags component of FCGI_BeginRequestBody
1253 |  */
1254 | #define FCGI_KEEP_CONN  1
1255 | 
1256 | /*
1257 |  * Values for role component of FCGI_BeginRequestBody
1258 |  */
1259 | #define FCGI_RESPONDER  1
1260 | #define FCGI_AUTHORIZER 2
1261 | #define FCGI_FILTER     3
1262 | 
1263 | typedef struct {
1264 |     unsigned char appStatusB3;
1265 |     unsigned char appStatusB2;
1266 |     unsigned char appStatusB1;
1267 |     unsigned char appStatusB0;
1268 |     unsigned char protocolStatus;
1269 |     unsigned char reserved[3];
1270 | } FCGI_EndRequestBody;
1271 | 
1272 | typedef struct {
1273 |     FCGI_Header header;
1274 |     FCGI_EndRequestBody body;
1275 | } FCGI_EndRequestRecord;
1276 | 
1277 | /*
1278 |  * Values for protocolStatus component of FCGI_EndRequestBody
1279 |  */
1280 | #define FCGI_REQUEST_COMPLETE 0
1281 | #define FCGI_CANT_MPX_CONN    1
1282 | #define FCGI_OVERLOADED       2
1283 | #define FCGI_UNKNOWN_ROLE     3
1284 | 
1285 | /*
1286 |  * Variable names for FCGI_GET_VALUES / FCGI_GET_VALUES_RESULT records
1287 |  */
1288 | #define FCGI_MAX_CONNS  "FCGI_MAX_CONNS"
1289 | #define FCGI_MAX_REQS   "FCGI_MAX_REQS"
1290 | #define FCGI_MPXS_CONNS "FCGI_MPXS_CONNS"
1291 | 
1292 | typedef struct {
1293 |     unsigned char type;    
1294 |     unsigned char reserved[7];
1295 | } FCGI_UnknownTypeBody;
1296 | 
1297 | typedef struct {
1298 |     FCGI_Header header;
1299 |     FCGI_UnknownTypeBody body;
1300 | } FCGI_UnknownTypeRecord;
1301 | 
1302 |

1303 |

1304 | 1305 |

1306 | 9. References 1307 |

1308 |

1309 | National Center for Supercomputer Applications, The Common Gateway 1310 | Interface, version CGI/1.1. 1311 |

1312 |

1313 | D.R.T. Robinson, The WWW 1314 | Common Gateway Interface Version 1.1, Internet-Draft, 15 February 1996. 1315 |

1316 | 1317 |

1318 |

1319 |

1320 | A. Table: Properties of the record types 1321 |

1322 |

1323 | The following chart lists all of the record types and indicates these properties of each: 1324 |

1325 |

1326 | 1327 |

1328 |
    1329 |
  • 1330 | WS->App: records of this type can only be sent by the Web server to the application. Records of 1331 | other types can only be sent by the application to the Web server. 1332 |

    1333 |

    1334 |
  • 1335 |
  • 1336 | 1337 | management: records of this type contain information that is not specific to a Web server request, 1338 | and use the null request ID. Records of other types contain request-specific information, and cannot use 1339 | the null request ID. 1340 |

    1341 |

    1342 |
  • 1343 |
  • 1344 | stream: records of this type form a stream, terminated by a record with empty 1345 | contentData. Records of other types are discrete; each carries a meaningful unit of data.
    1346 |
    1347 | 1348 |
  • 1349 |
1350 |
                               WS->App   management  stream
1351 | 
1352 |         FCGI_GET_VALUES           x          x
1353 |         FCGI_GET_VALUES_RESULT               x
1354 |         FCGI_UNKNOWN_TYPE                    x
1355 | 
1356 |         FCGI_BEGIN_REQUEST        x
1357 |         FCGI_ABORT_REQUEST        x
1358 |         FCGI_END_REQUEST
1359 |         FCGI_PARAMS               x                    x
1360 |         FCGI_STDIN                x                    x
1361 |         FCGI_DATA                 x                    x
1362 |         FCGI_STDOUT                                    x 
1363 |         FCGI_STDERR                                    x     
1364 | 
1365 | 
1366 | 
1367 |

1368 |

1369 |

1370 | B. Typical Protocol Message Flow 1371 | 1372 |

1373 |

1374 | Additional notational conventions for the examples: 1375 |

1376 |
    1377 |
  • 1378 | The contentData of stream records (FCGI_PARAMS, FCGI_STDIN, 1379 | FCGI_STDOUT, and FCGI_STDERR) is represented as a character string. A string ending in 1380 | " ... " is too long to display, so only a prefix is shown. 1381 |
  • 1382 | 1383 |
  • 1384 | Messages sent to the Web server are indented with respect to messages received from the Web server. 1385 |
  • 1386 |
  • 1387 | Messages are shown in the time sequence experienced by the application. 1388 |
  • 1389 |
1390 |

1391 | 1. A simple request with no data on stdin, and a successful response: 1392 |

1393 | 1394 |
{FCGI_BEGIN_REQUEST,   1, {FCGI_RESPONDER, 0}}
1395 | {FCGI_PARAMS,          1, "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "}
1396 | {FCGI_PARAMS,          1, ""}
1397 | {FCGI_STDIN,           1, ""}
1398 | 
1399 |     {FCGI_STDOUT,      1, "Content-type: text/html\r\n\r\n<html>\n<head> ... "}
1400 |     {FCGI_STDOUT,      1, ""}
1401 |     {FCGI_END_REQUEST, 1, {0, FCGI_REQUEST_COMPLETE}}
1402 | 
1403 |

1404 | 1405 | 2. Similar to example 1, but this time with data on stdin. The Web server chooses to send the 1406 | parameters using more FCGI_PARAMS records than before: 1407 |

1408 |
{FCGI_BEGIN_REQUEST,   1, {FCGI_RESPONDER, 0}}
1409 | {FCGI_PARAMS,          1, "\013\002SERVER_PORT80\013\016SER"}
1410 | {FCGI_PARAMS,          1, "VER_ADDR199.170.183.42 ... "}
1411 | {FCGI_PARAMS,          1, ""}
1412 | {FCGI_STDIN,           1, "quantity=100&item=3047936"}
1413 | {FCGI_STDIN,           1, ""}
1414 | 
1415 |     {FCGI_STDOUT,      1, "Content-type: text/html\r\n\r\n<html>\n<head> ... "}
1416 |     {FCGI_STDOUT,      1, ""}
1417 |     {FCGI_END_REQUEST, 1, {0, FCGI_REQUEST_COMPLETE}}
1418 | 
1419 | 
1420 |

1421 | 3. Similar to example 1, but this time the application detects an error. The application logs a message to 1422 | stderr, returns a page to the client, and returns non-zero exit status to the Web server. The 1423 | application chooses to send the page using more FCGI_STDOUT records: 1424 |

1425 |
{FCGI_BEGIN_REQUEST,   1, {FCGI_RESPONDER, 0}}
1426 | {FCGI_PARAMS,          1, "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "}
1427 | {FCGI_PARAMS,          1, ""}
1428 | {FCGI_STDIN,           1, ""}
1429 | 
1430 |     {FCGI_STDOUT,      1, "Content-type: text/html\r\n\r\n<ht"}
1431 |     {FCGI_STDERR,      1, "config error: missing SI_UID\n"}
1432 |     {FCGI_STDOUT,      1, "ml>\n<head> ... "}
1433 |     {FCGI_STDOUT,      1, ""}
1434 |     {FCGI_STDERR,      1, ""}
1435 |     {FCGI_END_REQUEST, 1, {938, FCGI_REQUEST_COMPLETE}}
1436 | 
1437 | 
1438 |

1439 | 4. Two instances of example 1, multiplexed onto a single connection. The first request is more difficult than 1440 | the second, so the application finishes the requests out of order: 1441 |

1442 |
{FCGI_BEGIN_REQUEST,   1, {FCGI_RESPONDER, FCGI_KEEP_CONN}}
1443 | {FCGI_PARAMS,          1, "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "}
1444 | {FCGI_PARAMS,          1, ""}
1445 | {FCGI_BEGIN_REQUEST,   2, {FCGI_RESPONDER, FCGI_KEEP_CONN}}
1446 | {FCGI_PARAMS,          2, "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "}
1447 | {FCGI_STDIN,           1, ""}
1448 | 
1449 |     {FCGI_STDOUT,      1, "Content-type: text/html\r\n\r\n"}
1450 | 
1451 | {FCGI_PARAMS,          2, ""}
1452 | {FCGI_STDIN,           2, ""}
1453 | 
1454 |     {FCGI_STDOUT,      2, "Content-type: text/html\r\n\r\n<html>\n<head> ... "}
1455 |     {FCGI_STDOUT,      2, ""}
1456 |     {FCGI_END_REQUEST, 2, {0, FCGI_REQUEST_COMPLETE}}
1457 |     {FCGI_STDOUT,      1, "<html>\n<head> ... "}
1458 |     {FCGI_STDOUT,      1, ""}
1459 |     {FCGI_END_REQUEST, 1, {0, FCGI_REQUEST_COMPLETE}}
1460 | 
1461 | 
1462 |

1463 |

1464 |
1465 |
1466 | © Copyright 1995, 1996 Open Market, Inc. / mbrown@openmarket.com 1467 |
1468 |
1469 | 1470 |
1471 |
1472 | 1473 |
1474 | 1475 |
1476 | 1477 |
1478 | 1481 |
1482 | 1483 | 1484 | 1485 | 1486 | 1487 | 1488 | 1489 | 1490 | 1491 | 1492 | 1500 | -------------------------------------------------------------------------------- /spec.md: -------------------------------------------------------------------------------- 1 | # FastCGI Specification 2 | 3 | Mark R. Brown 4 | Open Market, Inc. 5 | 6 | Document Version: 1.0 7 | 29 April 1996 8 | 9 | **Copyright © 1996 Open Market, Inc. 245 First Street, Cambridge, MA 02142 U.S.A.** 10 | **Tel: 617-621-9500 Fax: 617-621-1703 URL: http://www.openmarket.com/** 11 | 12 | **$Id: fcgi-spec.html,v 1.4 2002/02/25 00:42:59 robs Exp $** 13 | 14 | * * * 15 | 16 | 1. [Introduction](#1-introduction) 17 | 2. [Initial process state](#2-initial-process-state) 18 | 1. [Argument list](#21-argument-list) 19 | 2. [File descriptors](#22-file-descriptors) 20 | 3. [Environment variables](#23-environment-variables) 21 | 4. [Other state](#24-other-state) 22 | 3. [Protocol basics](#3-protocol-basics) 23 | 1. [Notation](#31-notation) 24 | 2. [Accepting transport connections](#32-accepting-transport-connections) 25 | 3. [Records](#33-records) 26 | 4. [Name-Value pairs](#34-name-value-pairs) 27 | 5. [Closing transport connections](#35-closing-transport-connections) 28 | 4. [Management record types](#4-management-record-types) 29 | 1. [`FCGI_GET_VALUES`, `FCGI_GET_VALUES_RESULT`](#41-fcgi_get_values-fcgi_get_values_result) 30 | 2. [`FCGI_UNKNOWN_TYPE`](#42-fcgi_unknown_type) 31 | 5. [Application record types](#5-application-record-types) 32 | 1. [`FCGI_BEGIN_REQUEST`](#51-fcgi_begin_request) 33 | 2. [Name-Value pair streams: `FCGI_PARAMS`](#52-name-value-pair-streams-fcgi_params) 34 | 3. [Byte streams: `FCGI_STDIN`, `FCGI_DATA`, `FCGI_STDOUT`, `FCGI_STDERR`](#53-byte-streams-fcgi_stdin-fcgi_data-fcgi_stdout-fcgi_stderr) 35 | 4. [`FCGI_ABORT_REQUEST`](#54-fcgi_abort_request) 36 | 5. [`FCGI_END_REQUEST`](#55-fcgi_end_request) 37 | 6. [Roles](#6-roles) 38 | 1. [Role protocols](#61-role-protocols) 39 | 2. [Responder](#62-responder) 40 | 3. [Authorizer](#63-authorizer) 41 | 4. [Filter](#64-filter) 42 | 7. [Errors](#7-errors) 43 | 8. [Types and constants](#8-types-and-constants) 44 | 9. [References](#9-references) 45 | 10. [Table: properties of the record types](#a-table-properties-of-the-record-types) 46 | 11. [Typical protocol message flow](#b-typical-protocol-message-flow) 47 | 48 | * * * 49 | 50 | ## 1. Introduction 51 | 52 | FastCGI is an open extension to CGI that provides high performance for all Internet applications without the penalties of Web server APIs. 53 | 54 | This specification has narrow goal: to specify, from an application perspective, the interface between a FastCGI application and a Web server that supports FastCGI. Many Web server features related to FastCGI, e.g. application management facilities, have nothing to do with the application to Web server interface, and are not described here. 55 | 56 | This specification is for Unix (more precisely, for POSIX systems that support Berkeley Sockets). The bulk of the specification is a simple communications protocol that is independent of byte ordering and will extend to other systems. 57 | 58 | We'll introduce FastCGI by comparing it with conventional Unix implementations of CGI/1.1. FastCGI is designed to support long-lived application processes, i.e. *application servers*. That's a major difference compared with conventional Unix implementations of CGI/1.1, which construct an application process, use it respond to one request, and have it exit. 59 | 60 | The initial state of a FastCGI process is more spartan than the initial state of a CGI/1.1 process, because the FastCGI process doesn't begin life connected to anything. It doesn't have the conventional open files `stdin`, `stdout`, and `stderr`, and it doesn't receive much information through environment variables. The key piece of initial state in a FastCGI process is a listening socket, through which it accepts connections from a Web server. 61 | 62 | After a FastCGI process accepts a connection on its listening socket, the process executes a simple protocol to receive and send data. The protocol serves two purposes. First, the protocol multiplexes a single transport connection between several independent FastCGI requests. This supports applications that are able to process concurrent requests using event-driven or multi-threaded programming techniques. Second, within each request the protocol provides several independent data streams in each direction. This way, for instance, both `stdout` and `stderr` data pass over a single transport connection from the application to the Web server, rather than requiring separate pipes as with CGI/1.1. 63 | 64 | A FastCGI application plays one of several well-defined *roles*. The most familiar is the *Responder* role, in which the application receives all the information associated with an HTTP request and generates an HTTP response; that's the role CGI/1.1 programs play. A second role is *Authorizer*, in which the application receives all the information associated with an HTTP request and generates an authorized/unauthorized decision. A third role is *Filter*, in which the application receives all the information associated with an HTTP request, plus an extra stream of data from a file stored on the Web server, and generates a "filtered" version of the data stream as an HTTP response. The framework is extensible so that more FastCGI can be defined later. 65 | 66 | In the remainder of this specification the terms "FastCGI application," "application process," or "application server" are abbreviated to "application" whenever that won't cause confusion. 67 | 68 | ## 2. Initial process state 69 | 70 | ### 2.1. Argument list 71 | 72 | By default the Web server creates an argument list containing a single element, the name of the application, taken to be the last component of the executable's path name. The Web server may provide a way to specify a different application name, or a more elaborate argument list. 73 | 74 | Note that the file executed by the Web server might be an interpreter file (a text file that starts with the characters `#!`), in which case the application's argument list is constructed as described in the `execve` manpage. 75 | 76 | ### 2.2. File descriptors 77 | 78 | The Web server leaves a single file descriptor, `FCGI_LISTENSOCK_FILENO`, open when the application begins execution. This descriptor refers to a listening socket created by the Web server. 79 | 80 | `FCGI_LISTENSOCK_FILENO` equals `STDIN_FILENO`. The standard descriptors `STDOUT_FILENO` and `STDERR_FILENO` are closed when the application begins execution. A reliable method for an application to determine whether it was invoked using CGI or FastCGI is to call `getpeername(FCGI_LISTENSOCK_FILENO)`, which returns -1 with `errno` set to `ENOTCONN` for a FastCGI application. 81 | 82 | The Web server's choice of reliable transport, Unix stream pipes (`AF_UNIX`) or TCP/IP (`AF_INET`), is implicit in the internal state of the `FCGI_LISTENSOCK_FILENO` socket. 83 | 84 | ### 2.3. Environment variables 85 | 86 | The Web server may use environment variables to pass parameters to the application. This specification defines one such variable, `FCGI_WEB_SERVER_ADDRS`; we expect more to be defined as the specification evolves. The Web server may provide a way to bind other environment variables, such as the `PATH` variable. 87 | 88 | ### 2.4. Other state 89 | 90 | The Web server may provide a way to specify other components of an application's initial process state, such as the priority, user ID, group ID, root directory, and working directory of the process. 91 | 92 | ## 3. Protocol basics 93 | 94 | ### 3.1. Notation 95 | 96 | We use C language notation to define protocol message formats. All structure elements are defined in terms of the `unsigned char` type, and are arranged so that an ISO C compiler lays them out in the obvious manner, with no padding. The first byte defined in the structure is transmitted first, the second byte second, etc. 97 | 98 | We use two conventions to abbreviate our definitions. 99 | 100 | First, when two adjacent structure components are named identically except for the suffixes "`B1`" and "`B0`", it means that the two components may be viewed as a single number, computed as `B1<<8 + B0`. The name of this single number is the name of the components, minus the suffixes. This convention generalizes in an obvious way to handle numbers represented in more than two bytes. 101 | 102 | Second, we extend C `structs` to allow the form 103 | 104 | ```c 105 | struct { 106 | unsigned char mumbleLengthB1; 107 | unsigned char mumbleLengthB0; 108 | ... /* other stuff */ 109 | unsigned char mumbleData[mumbleLength]; 110 | }; 111 | ``` 112 | 113 | meaning a structure of varying length, where the length of a component is determined by the values of the indicated earlier component or components. 114 | 115 | ### 3.2. Accepting transport connections 116 | 117 | A FastCGI application calls `accept()` on the socket referred to by file descriptor `FCGI_LISTENSOCK_FILENO` to accept a new transport connection. If the `accept()` succeeds, and the `FCGI_WEB_SERVER_ADDRS` environment variable is bound, the application application immediately performs the following special processing: 118 | 119 | * `FCGI_WEB_SERVER_ADDRS`: The value is a list of valid IP addresses for the Web server. 120 | 121 | If `FCGI_WEB_SERVER_ADDRS` was bound, the application checks the peer IP address of the new connection for membership in the list. If the check fails (including the possibility that the connection didn't use TCP/IP transport), the application responds by closing the connection. 122 | 123 | `FCGI_WEB_SERVER_ADDRS` is expressed as a comma-separated list of IP addresses. Each IP address is written as four decimal numbers in the range `[0..255]` separated by decimal points. So one legal binding for this variable is `FCGI_WEB_SERVER_ADDRS=199.170.183.28,199.170.183.71`. 124 | 125 | An application may accept several concurrent transport connections, but it need not do so. 126 | 127 | ### 3.3. Records 128 | 129 | Applications execute requests from a Web server using a simple protocol. Details of the protocol depend upon the application's role, but roughly speaking the Web server first sends parameters and other data to the application, then the application sends result data to the Web server, and finally the application sends the Web server an indication that the request is complete. 130 | 131 | All data that flows over the transport connection is carried in *FastCGI records*. FastCGI records accomplish two things. First, records multiplex the transport connection between several independent FastCGI requests. This multiplexing supports applications that are able to process concurrent requests using event-driven or multi-threaded programming techniques. Second, records provide several independent data streams in each direction within a single request. This way, for instance, both `stdout` and `stderr` data can pass over a single transport connection from the application to the Web server, rather than requiring separate connections. 132 | 133 | ```c 134 | typedef struct { 135 | unsigned char version; 136 | unsigned char type; 137 | unsigned char requestIdB1; 138 | unsigned char requestIdB0; 139 | unsigned char contentLengthB1; 140 | unsigned char contentLengthB0; 141 | unsigned char paddingLength; 142 | unsigned char reserved; 143 | unsigned char contentData[contentLength]; 144 | unsigned char paddingData[paddingLength]; 145 | } FCGI_Record; 146 | ``` 147 | 148 | A FastCGI record consists of a fixed-length prefix followed by a variable number of content and padding bytes. A record contains seven components: 149 | 150 | * `version`: Identifies the FastCGI protocol version. This specification documents `FCGI_VERSION_1`. 151 | 152 | * `type`: Identifies the FastCGI record type, i.e. the general function that the record performs. Specific record types and their functions are detailed in later sections. 153 | 154 | * `requestId`: Identifies the *FastCGI request* to which the record belongs. 155 | 156 | * `contentLength`: The number of bytes in the `contentData` component of the record. 157 | 158 | * `paddingLength`: The number of bytes in the `paddingData` component of the record. 159 | 160 | * `contentData`: Between 0 and 65535 bytes of data, interpreted according to the record type. 161 | 162 | * `paddingData`: Between 0 and 255 bytes of data, which are ignored. 163 | 164 | We use a relaxed C `struct` initializer syntax to specify constant FastCGI records. We omit the `version` component, ignore padding, and treat `requestId` as a number. Thus `{FCGI_END_REQUEST, 1, {FCGI_REQUEST_COMPLETE,0}}` is a record with `type == FCGI_END_REQUEST`, `requestId == 1`, and `contentData == {FCGI_REQUEST_COMPLETE,0}`. 165 | 166 | #### Padding 167 | 168 | The protocol allows senders to pad the records they send, and requires receivers to interpret the `paddingLength` and skip the `paddingData`. Padding allows senders to keep data aligned for more efficient processing. Experience with the X window system protocols shows the performance benefit of such alignment. 169 | 170 | We recommend that records be placed on boundaries that are multiples of eight bytes. The fixed-length portion of a `FCGI_Record` is eight bytes. 171 | 172 | #### Managing request IDs 173 | 174 | The Web server re-uses FastCGI request IDs; the application keeps track of the current state of each request ID on a given transport connection. A request ID `R` becomes active when the application receives a record `{FCGI_BEGIN_REQUEST, R, ...}` and becomes inactive when the application sends a record `{FCGI_END_REQUEST, R, ...}` to the Web server. 175 | 176 | While a request ID `R` is inactive, the application ignores records with `requestId == R`, except for `FCGI_BEGIN_REQUEST` records as just described. 177 | 178 | The Web server attempts to keep FastCGI request IDs small. That way the application can keep track of request ID states using a short array rather than a long array or a hash table. An application also has the option of accepting only one request at a time. In this case the application simply checks incoming `requestId` values against the current request ID. 179 | 180 | #### Types of record types 181 | 182 | There are two useful ways of classifying FastCGI record types. 183 | 184 | The first distinction is between *management* records and *application* records. A management record contains information that is not specific to any Web server request, such as information about the protocol capabilities of the application. An application record contains information about a particular request, identified by the `requestId` component. 185 | 186 | Management records have a `requestId` value of zero, also called the *null request ID*. Application records have a nonzero `requestId`. 187 | 188 | The second distinction is between *discrete* and *stream* records. A discrete record contains a meaningful unit of data all by itself. A stream record is part of a *stream*, i.e. a series of zero or more non-empty records (`length != 0`) of the stream type, followed by an empty record (`length == 0`) of the stream type. The `contentData` components of a stream's records, when concatenated, form a byte sequence; this byte sequence is the value of the stream. Therefore the value of a stream is independent of how many records it contains or how its bytes are divided among the non-empty records. 189 | 190 | These two classifications are independent. Among the record types defined in this version of the FastCGI protocol, all management record types are also discrete record types, and nearly all application record types are stream record types. But three application record types are discrete, and nothing prevents defining a management record type that's a stream in some later version of the protocol. 191 | 192 | ### 3.4. Name-Value pairs 193 | 194 | In many of their roles, FastCGI applications need to read and write varying numbers of variable-length values. So it is useful to adopt a standard format for encoding a name-value pair. 195 | 196 | FastCGI transmits a name-value pair as the length of the name, followed by the length of the value, followed by the name, followed by the value. Lengths of 127 bytes and less can be encoded in one byte, while longer lengths are always encoded in four bytes: 197 | 198 | ```c 199 | typedef struct { 200 | unsigned char nameLengthB0; /* nameLengthB0 >> 7 == 0 */ 201 | unsigned char valueLengthB0; /* valueLengthB0 >> 7 == 0 */ 202 | unsigned char nameData[nameLength]; 203 | unsigned char valueData[valueLength]; 204 | } FCGI_NameValuePair11; 205 | 206 | typedef struct { 207 | unsigned char nameLengthB0; /* nameLengthB0 >> 7 == 0 */ 208 | unsigned char valueLengthB3; /* valueLengthB3 >> 7 == 1 */ 209 | unsigned char valueLengthB2; 210 | unsigned char valueLengthB1; 211 | unsigned char valueLengthB0; 212 | unsigned char nameData[nameLength]; 213 | unsigned char valueData[valueLength 214 | ((B3 & 0x7f) << 24) + (B2 << 16) + (B1 << 8) + B0]; 215 | } FCGI_NameValuePair14; 216 | 217 | typedef struct { 218 | unsigned char nameLengthB3; /* nameLengthB3 >> 7 == 1 */ 219 | unsigned char nameLengthB2; 220 | unsigned char nameLengthB1; 221 | unsigned char nameLengthB0; 222 | unsigned char valueLengthB0; /* valueLengthB0 >> 7 == 0 */ 223 | unsigned char nameData[nameLength 224 | ((B3 & 0x7f) << 24) + (B2 << 16) + (B1 << 8) + B0]; 225 | unsigned char valueData[valueLength]; 226 | } FCGI_NameValuePair41; 227 | 228 | typedef struct { 229 | unsigned char nameLengthB3; /* nameLengthB3 >> 7 == 1 */ 230 | unsigned char nameLengthB2; 231 | unsigned char nameLengthB1; 232 | unsigned char nameLengthB0; 233 | unsigned char valueLengthB3; /* valueLengthB3 >> 7 == 1 */ 234 | unsigned char valueLengthB2; 235 | unsigned char valueLengthB1; 236 | unsigned char valueLengthB0; 237 | unsigned char nameData[nameLength 238 | ((B3 & 0x7f) << 24) + (B2 << 16) + (B1 << 8) + B0]; 239 | unsigned char valueData[valueLength 240 | ((B3 & 0x7f) << 24) + (B2 << 16) + (B1 << 8) + B0]; 241 | } FCGI_NameValuePair44; 242 | ``` 243 | 244 | The high-order bit of the first byte of a length indicates the length's encoding. A high-order zero implies a one-byte encoding, a one a four-byte encoding. 245 | 246 | This name-value pair format allows the sender to transmit binary values without additional encoding, and enables the receiver to allocate the correct amount of storage immediately even for large values. 247 | 248 | ### 3.5. Closing transport connections 249 | 250 | The Web server controls the lifetime of transport connections. The Web server can close a connection when no requests are active. Or the Web server can delegate close authority to the application (see `FCGI_BEGIN_REQUEST`). In this case the application closes the connection at the end of a specified request. 251 | 252 | This flexibility accommodates a variety of application styles. Simple applications will process one request at a time and accept a new transport connection for each request. More complex applications will process concurrent requests, over one or multiple transport connections, and will keep transport connections open for long periods of time. 253 | 254 | A simple application gets a significant performance boost by closing the transport connection when it has finished writing its response. The Web server needs to control the connection lifetime for long-lived connections. 255 | 256 | When an application closes a connection or finds that a connection has closed, the application initiates a new connection. 257 | 258 | ## 4. Management record types 259 | 260 | ### 4.1. `FCGI_GET_VALUES`, `FCGI_GET_VALUES_RESULT` 261 | 262 | The Web server can query specific variables within the application. The server will typically perform a query on application startup in order to to automate certain aspects of system configuration. 263 | 264 | The application receives a query as a record `{FCGI_GET_VALUES, 0, ...}`. The `contentData` portion of a `FCGI_GET_VALUES` record contains a sequence of name-value pairs with empty values. 265 | 266 | The application responds by sending a record `{FCGI_GET_VALUES_RESULT, 0, ...}` with the values supplied. If the application doesn't understand a variable name that was included in the query, it omits that name from the response. 267 | 268 | `FCGI_GET_VALUES` is designed to allow an open-ended set of variables. The initial set provides information to help the server perform application and connection management: 269 | 270 | * `FCGI_MAX_CONNS`: The maximum number of concurrent transport connections this application will accept, e.g. `"1"` or `"10"`. 271 | 272 | * `FCGI_MAX_REQS`: The maximum number of concurrent requests this application will accept, e.g. `"1"` or `"50"`. 273 | 274 | * `FCGI_MPXS_CONNS`: `"0"` if this application does not multiplex connections (i.e. handle concurrent requests over each connection), `"1"` otherwise. 275 | 276 | An application may receive a `FCGI_GET_VALUES` record at any time. The application's response should not involve the application proper but only the FastCGI library. 277 | 278 | ### 4.2. `FCGI_UNKNOWN_TYPE` 279 | 280 | The set of management record types is likely to grow in future versions of this protocol. To provide for this evolution, the protocol includes the `FCGI_UNKNOWN_TYPE` management record. When an application receives a management record whose type `T` it does not understand, the application responds with `{FCGI_UNKNOWN_TYPE, 0, {T}}`. 281 | 282 | The `contentData` component of a `FCGI_UNKNOWN_TYPE` record has the form: 283 | 284 | ```c 285 | typedef struct { 286 | unsigned char type; 287 | unsigned char reserved[7]; 288 | } FCGI_UnknownTypeBody; 289 | ``` 290 | 291 | The type component is the type of the unrecognized management record. 292 | 293 | ## 5. Application record types 294 | 295 | ### 5.1. `FCGI_BEGIN_REQUEST` 296 | 297 | The Web server sends a `FCGI_BEGIN_REQUEST` record to start a request. 298 | 299 | The `contentData` component of a `FCGI_BEGIN_REQUEST` record has the form: 300 | 301 | ```c 302 | typedef struct { 303 | unsigned char roleB1; 304 | unsigned char roleB0; 305 | unsigned char flags; 306 | unsigned char reserved[5]; 307 | } FCGI_BeginRequestBody; 308 | ``` 309 | 310 | The `role` component sets the role the Web server expects the application to play. The currently-defined roles are: 311 | 312 | * `FCGI_RESPONDER` 313 | * `FCGI_AUTHORIZER` 314 | * `FCGI_FILTER` 315 | 316 | Roles are described in more detail in [Section 6](#roles) below. 317 | 318 | The `flags` component contains a bit that controls connection shutdown: 319 | 320 | * `flags & FCGI_KEEP_CONN`: If zero, the application closes the connection after responding to this request. If not zero, the application does not close the connection after responding to this request; the Web server retains responsibility for the connection. 321 | 322 | ### 5.2. Name-Value pair streams: `FCGI_PARAMS` 323 | 324 | `FCGI_PARAMS` is a stream record type used in sending name-value pairs from the Web server to the application. The name-value pairs are sent down the stream one after the other, in no specified order. 325 | 326 | ### 5.3. Byte streams: `FCGI_STDIN`, `FCGI_DATA`, `FCGI_STDOUT`, `FCGI_STDERR` 327 | 328 | `FCGI_STDIN` is a stream record type used in sending arbitrary data from the Web server to the application. `FCGI_DATA` is a second stream record type used to send additional data to the application. 329 | 330 | `FCGI_STDOUT` and `FCGI_STDERR` are stream record types for sending arbitrary data and error data respectively from the application to the Web server. 331 | 332 | ### 5.4. `FCGI_ABORT_REQUEST` 333 | 334 | The Web server sends a `FCGI_ABORT_REQUEST` record to abort a request. After receiving `{FCGI_ABORT_REQUEST, R}`, the application responds as soon as possible with `{FCGI_END_REQUEST, R, {FCGI_REQUEST_COMPLETE, appStatus}}`. This is truly a response from the application, not a low-level acknowledgement from the FastCGI library. 335 | 336 | A Web server aborts a FastCGI request when an HTTP client closes its transport connection while the FastCGI request is running on behalf of that client. The situation may seem unlikely; most FastCGI requests will have short response times, with the Web server providing output buffering if the client is slow. But the FastCGI application may be delayed communicating with another system, or performing a server push. 337 | 338 | When a Web server is not multiplexing requests over a transport connection, the Web server can abort a request by closing the request's transport connection. But with multiplexed requests, closing the transport connection has the unfortunate effect of aborting all the requests on the connection. 339 | 340 | ### 5.5. `FCGI_END_REQUEST` 341 | 342 | The application sends a `FCGI_END_REQUEST` record to terminate a request, either because the application has processed the request or because the application has rejected the request. 343 | 344 | The `contentData` component of a `FCGI_END_REQUEST` record has the form: 345 | 346 | ```c 347 | typedef struct { 348 | unsigned char appStatusB3; 349 | unsigned char appStatusB2; 350 | unsigned char appStatusB1; 351 | unsigned char appStatusB0; 352 | unsigned char protocolStatus; 353 | unsigned char reserved[3]; 354 | } FCGI_EndRequestBody; 355 | ``` 356 | 357 | The `appStatus` component is an application-level status code. Each role documents its usage of `appStatus`. 358 | 359 | The `protocolStatus` component is a protocol-level status code; the possible `protocolStatus` values are: 360 | 361 | * `FCGI_REQUEST_COMPLETE`: normal end of request. 362 | 363 | * `FCGI_CANT_MPX_CONN`: rejecting a new request. This happens when a Web server sends concurrent requests over one connection to an application that is designed to process one request at a time per connection. 364 | 365 | * `FCGI_OVERLOADED`: rejecting a new request. This happens when the application runs out of some resource, e.g. database connections. 366 | 367 | * `FCGI_UNKNOWN_ROLE`: rejecting a new request. This happens when the Web server has specified a role that is unknown to the application. 368 | 369 | ## 6. Roles 370 | 371 | ### 6.1. Role protocols 372 | 373 | Role protocols only include records with application record types. They transfer essentially all data using streams. 374 | 375 | To make the protocols reliable and to simplify application programming, role protocols are designed to use *nearly sequential marshalling*. In a protocol with strictly sequential marshalling, the application receives its first input, then its second, etc. until it has received them all. Similarly, the application sends its first output, then its second, etc. until it has sent them all. Inputs are not interleaved with each other, and outputs are not interleaved with each other. 376 | 377 | The sequential marshalling rule is too restrictive for some FastCGI roles, because CGI programs can write to both stdout and stderr without timing restrictions. So role protocols that use both `FCGI_STDOUT` and `FCGI_STDERR` allow these two streams to be interleaved. 378 | 379 | All role protocols use the `FCGI_STDERR` stream just the way `stderr` is used in conventional applications programming: to report application-level errors in an intelligible way. Use of the `FCGI_STDERR` stream is always optional. If an application has no errors to report, it sends either no `FCGI_STDERR` records or one zero-length `FCGI_STDERR` record. 380 | 381 | When a role protocol calls for transmitting a stream other than `FCGI_STDERR`, at least one record of the stream type is always transmitted, even if the stream is empty. 382 | 383 | Again in the interests of reliable protocols and simplified application programming, role protocols are designed to be *nearly request-response*. In a truly request-response protocol, the application receives all of its input records before sending its first output record. Request-response protocols don't allow pipelining. 384 | 385 | The request-response rule is too restrictive for some FastCGI roles; after all, CGI programs aren't restricted to read all of stdin before starting to write stdout. So some role protocols allow that specific possibility. First the application receives all of its inputs except for a final stream input. As the application begins to receive the final stream input, it can begin writing its output. 386 | 387 | When a role protocol uses `FCGI_PARAMS` to transmit textual values, such as the values that CGI programs obtain from environment variables, the length of the value does not include the terminating null byte, and the value itself does not include a null byte. An application that needs to provide `environ(7)` format name-value pairs must insert an equal sign between the name and value and append a null byte after the value. 388 | 389 | Role protocols do not support the non-parsed header feature of CGI. FastCGI applications set response status using the `Status` and `Location` CGI headers. 390 | 391 | ### 6.2. Responder 392 | 393 | A Responder FastCGI application has the same purpose as a CGI/1.1 program: It receives all the information associated with an HTTP request and generates an HTTP response. 394 | 395 | It suffices to explain how each element of CGI/1.1 is emulated by a Responder: 396 | 397 | * The Responder application receives CGI/1.1 environment variables from the Web server over `FCGI_PARAMS`. 398 | 399 | * Next the Responder application receives CGI/1.1 `stdin` data from the Web server over `FCGI_STDIN`. The application receives at most `CONTENT_LENGTH` bytes from this stream before receiving the end-of-stream indication. (The application receives less than `CONTENT_LENGTH` bytes only if the HTTP client fails to provide them, e.g. because the client crashed.) 400 | 401 | * The Responder application sends CGI/1.1 `stdout` data to the Web server over `FCGI_STDOUT`, and CGI/1.1 `stderr` data over `FCGI_STDERR`. The application sends these concurrently, not one after the other. The application must wait to finish reading `FCGI_PARAMS` before it begins writing `FCGI_STDOUT` and `FCGI_STDERR`, but it needn't finish reading from `FCGI_STDIN` before it begins writing these two streams. 402 | 403 | * After sending all its `stdout` and `stderr` data, the Responder application sends a `FCGI_END_REQUEST` record. The application sets the `protocolStatus` component to `FCGI_REQUEST_COMPLETE` and the `appStatus` component to the status code that the CGI program would have returned via the `exit` system call. 404 | 405 | A Responder performing an update, e.g. implementing a `POST` method, should compare the number of bytes received on `FCGI_STDIN` with `CONTENT_LENGTH` and abort the update if the two numbers are not equal. 406 | 407 | ### 6.3. Authorizer 408 | 409 | An Authorizer FastCGI application receives all the information associated with an HTTP request and generates an authorized/unauthorized decision. In case of an authorized decision the Authorizer can also associate name-value pairs with the HTTP request; when giving an unauthorized decision the Authorizer sends a complete response to the HTTP client. 410 | 411 | Since CGI/1.1 defines a perfectly good way to represent the information associated with an HTTP request, Authorizers use the same representation: 412 | 413 | * The Authorizer application receives HTTP request information from the Web server on the `FCGI_PARAMS` stream, in the same format as a Responder. The Web server does not send `CONTENT_LENGTH`, `PATH_INFO`, `PATH_TRANSLATED`, and `SCRIPT_NAME` headers. 414 | 415 | * The Authorizer application sends `stdout` and `stderr` data in the same manner as a Responder. The CGI/1.1 response status specifies the disposition of the request. If the application sends status 200 (OK), the Web server allows access. Depending upon its configuration the Web server may proceed with other access checks, including requests to other Authorizers. 416 | 417 | An Authorizer application's 200 response may include headers whose names are prefixed with `Variable-`. These headers communicate name-value pairs from the application to the Web server. For instance, the response header 418 | 419 | ``` 420 | Variable-AUTH_METHOD: database lookup 421 | ``` 422 | 423 | transmits the value `"database lookup"` with name `AUTH-METHOD`. The server associates such name-value pairs with the HTTP request and includes them in subsequent CGI or FastCGI requests performed in processing the HTTP request. When the application gives a 200 response, the server ignores response headers whose names aren't prefixed with `Variable-` prefix, and ignores any response content. 424 | 425 | For Authorizer response status values other than "200" (OK), the Web server denies access and sends the response status, headers, and content back to the HTTP client. 426 | 427 | ### 6.4. Filter 428 | 429 | A Filter FastCGI application receives all the information associated with an HTTP request, plus an extra stream of data from a file stored on the Web server, and generates a "filtered" version of the data stream as an HTTP response. 430 | 431 | A Filter is similar in functionality to a Responder that takes a data file as a parameter. The difference is that with a Filter, both the data file and the Filter itself can be access controlled using the Web server's access control mechanisms, while a Responder that takes the name of a data file as a parameter must perform its own access control checks on the data file. 432 | 433 | The steps taken by a Filter are similar to those of a Responder. The server presents the Filter with environment variables first, then standard input (normally form `POST` data), finally the data file input: 434 | 435 | * Like a Responder, the Filter application receives name-value pairs from the Web server over `FCGI_PARAMS`. Filter applications receive two Filter-specific variables: `FCGI_DATA_LAST_MOD` and `FCGI_DATA_LENGTH`. 436 | 437 | * Next the Filter application receives CGI/1.1 `stdin` data from the Web server over `FCGI_STDIN`. The application receives at most `CONTENT_LENGTH` bytes from this stream before receiving the end-of-stream indication. (The application receives less than `CONTENT_LENGTH` bytes only if the HTTP client fails to provide them, e.g. because the client crashed.) 438 | 439 | * Next the Filter application receives the file data from the Web server over `FCGI_DATA`. This file's last modification time (expressed as an integer number of seconds since the epoch January 1, 1970 UTC) is `FCGI_DATA_LAST_MOD`; the application may consult this variable and respond from a cache without reading the file data. The application reads at most `FCGI_DATA_LENGTH` bytes from this stream before receiving the end-of-stream indication. 440 | 441 | * The Filter application sends CGI/1.1 `stdout` data to the Web server over `FCGI_STDOUT`, and CGI/1.1 `stderr` data over `FCGI_STDERR`. The application sends these concurrently, not one after the other. The application must wait to finish reading `FCGI_STDIN` before it begins writing `FCGI_STDOUT` and `FCGI_STDERR`, but it needn't finish reading from `FCGI_DATA` before it begins writing these two streams. 442 | 443 | * After sending all its `stdout` and `stderr` data, the application sends a `FCGI_END_REQUEST` record. The application sets the `protocolStatus` component to `FCGI_REQUEST_COMPLETE` and the `appStatus` component to the status code that a similar CGI program would have returned via the `exit` system call. 444 | 445 | A Filter should compare the number of bytes received on `FCGI_STDIN` with `CONTENT_LENGTH` and on `FCGI_DATA` with `FCGI_DATA_LENGTH`. If the numbers don't match and the Filter is a query, the Filter response should provide an indication that data is missing. If the numbers don't match and the Filter is an update, the Filter should abort the update. 446 | 447 | ## 7. Errors 448 | 449 | A FastCGI application exits with zero status to indicate that it terminated on purpose, e.g. in order to perform a crude form of garbage collection. A FastCGI application that exits with nonzero status is assumed to have crashed. How a Web server or other application manager responds to applications that exit with zero or nonzero status is outside the scope of this specification. 450 | 451 | A Web server can request that a FastCGI application exit by sending it `SIGTERM`. If the application ignores `SIGTERM` the Web server can resort to `SIGKILL`. 452 | 453 | FastCGI applications report application-level errors with the `FCGI_STDERR` stream and the `appStatus` component of the `FCGI_END_REQUEST` record. In many cases an error will be reported directly to the user via the `FCGI_STDOUT` stream. 454 | 455 | On Unix, applications report lower-level errors, including FastCGI protocol errors and syntax errors in FastCGI environment variables, to `syslog`. Depending upon the severity of the error, the application may either continue or exit with nonzero status. 456 | 457 | ## 8. Types and constants 458 | 459 | ```c 460 | /* 461 | * Listening socket file number 462 | */ 463 | #define FCGI_LISTENSOCK_FILENO 0 464 | 465 | typedef struct { 466 | unsigned char version; 467 | unsigned char type; 468 | unsigned char requestIdB1; 469 | unsigned char requestIdB0; 470 | unsigned char contentLengthB1; 471 | unsigned char contentLengthB0; 472 | unsigned char paddingLength; 473 | unsigned char reserved; 474 | } FCGI_Header; 475 | 476 | /* 477 | * Number of bytes in a FCGI_Header. Future versions of the protocol 478 | * will not reduce this number. 479 | */ 480 | #define FCGI_HEADER_LEN 8 481 | 482 | /* 483 | * Value for version component of FCGI_Header 484 | */ 485 | #define FCGI_VERSION_1 1 486 | 487 | /* 488 | * Values for type component of FCGI_Header 489 | */ 490 | #define FCGI_BEGIN_REQUEST 1 491 | #define FCGI_ABORT_REQUEST 2 492 | #define FCGI_END_REQUEST 3 493 | #define FCGI_PARAMS 4 494 | #define FCGI_STDIN 5 495 | #define FCGI_STDOUT 6 496 | #define FCGI_STDERR 7 497 | #define FCGI_DATA 8 498 | #define FCGI_GET_VALUES 9 499 | #define FCGI_GET_VALUES_RESULT 10 500 | #define FCGI_UNKNOWN_TYPE 11 501 | #define FCGI_MAXTYPE (FCGI_UNKNOWN_TYPE) 502 | 503 | /* 504 | * Value for requestId component of FCGI_Header 505 | */ 506 | #define FCGI_NULL_REQUEST_ID 0 507 | 508 | typedef struct { 509 | unsigned char roleB1; 510 | unsigned char roleB0; 511 | unsigned char flags; 512 | unsigned char reserved[5]; 513 | } FCGI_BeginRequestBody; 514 | 515 | typedef struct { 516 | FCGI_Header header; 517 | FCGI_BeginRequestBody body; 518 | } FCGI_BeginRequestRecord; 519 | 520 | /* 521 | * Mask for flags component of FCGI_BeginRequestBody 522 | */ 523 | #define FCGI_KEEP_CONN 1 524 | 525 | /* 526 | * Values for role component of FCGI_BeginRequestBody 527 | */ 528 | #define FCGI_RESPONDER 1 529 | #define FCGI_AUTHORIZER 2 530 | #define FCGI_FILTER 3 531 | 532 | typedef struct { 533 | unsigned char appStatusB3; 534 | unsigned char appStatusB2; 535 | unsigned char appStatusB1; 536 | unsigned char appStatusB0; 537 | unsigned char protocolStatus; 538 | unsigned char reserved[3]; 539 | } FCGI_EndRequestBody; 540 | 541 | typedef struct { 542 | FCGI_Header header; 543 | FCGI_EndRequestBody body; 544 | } FCGI_EndRequestRecord; 545 | 546 | /* 547 | * Values for protocolStatus component of FCGI_EndRequestBody 548 | */ 549 | #define FCGI_REQUEST_COMPLETE 0 550 | #define FCGI_CANT_MPX_CONN 1 551 | #define FCGI_OVERLOADED 2 552 | #define FCGI_UNKNOWN_ROLE 3 553 | 554 | /* 555 | * Variable names for FCGI_GET_VALUES / FCGI_GET_VALUES_RESULT records 556 | */ 557 | #define FCGI_MAX_CONNS "FCGI_MAX_CONNS" 558 | #define FCGI_MAX_REQS "FCGI_MAX_REQS" 559 | #define FCGI_MPXS_CONNS "FCGI_MPXS_CONNS" 560 | 561 | typedef struct { 562 | unsigned char type; 563 | unsigned char reserved[7]; 564 | } FCGI_UnknownTypeBody; 565 | 566 | typedef struct { 567 | FCGI_Header header; 568 | FCGI_UnknownTypeBody body; 569 | } FCGI_UnknownTypeRecord; 570 | ``` 571 | 572 | ## 9. References 573 | 574 | National Center for Supercomputer Applications, [The Common Gateway Interface](http://hoohoo.ncsa.illinois.edu/cgi/), version CGI/1.1. 575 | 576 | D.R.T. Robinson, [The WWW Common Gateway Interface Version 1.1](http://cgi-spec.golux.com/), Internet-Draft, 15 February 1996. 577 | 578 | ### Updated references 579 | 580 | W3C, [CGI: Common Gateway Interface](https://www.w3.org/CGI/) 581 | 582 | Robinson, D. and K. Coar, [The Common Gateway Interface (CGI) Version 1.1](https://tools.ietf.org/html/rfc3875), RFC 3875, DOI 10.17487/RFC3875, October 2004 583 | 584 | ## A. Table: Properties of the record types 585 | 586 | The following chart lists all of the record types and indicates these properties of each: 587 | 588 | * **WS->App:** records of this type can only be sent by the Web server to the application. Records of other types can only be sent by the application to the Web server. 589 | 590 | * **management:** records of this type contain information that is not specific to a Web server request, and use the null request ID. Records of other types contain request-specific information, and cannot use the null request ID. 591 | 592 | * **stream:** records of this type form a stream, terminated by a record with empty `contentData`. Records of other types are discrete; each carries a meaningful unit of data. 593 | 594 | | | WS->App | management | stream | 595 | |--------------------------|---------|------------|---------| 596 | | `FCGI_GET_VALUES` | x | x | | 597 | | `FCGI_GET_VALUES_RESULT` | | x | | 598 | | `FCGI_UNKNOWN_TYPE` | | x | | 599 | | `FCGI_BEGIN_REQUEST` | x | | | 600 | | `FCGI_ABORT_REQUEST` | x | | | 601 | | `FCGI_END_REQUEST` | | | | 602 | | `FCGI_PARAMS` | x | | x | 603 | | `FCGI_STDIN` | x | | x | 604 | | `FCGI_DATA` | x | | x | 605 | | `FCGI_STDOUT` | | | x | 606 | | `FCGI_STDERR` | | | x | 607 | 608 | ## B. Typical protocol message flow 609 | 610 | Additional notational conventions for the examples: 611 | 612 | * The `contentData` of stream records (`FCGI_PARAMS`, `FCGI_STDIN`, `FCGI_STDOUT`, and `FCGI_STDERR`) is represented as a character string. A string ending in `" ... "` is too long to display, so only a prefix is shown. 613 | * Messages sent to the Web server are indented with respect to messages received from the Web server. 614 | * Messages are shown in the time sequence experienced by the application. 615 | 616 | 1\. A simple request with no data on `stdin`, and a successful response: 617 | 618 | ```c 619 | {FCGI_BEGIN_REQUEST, 1, {FCGI_RESPONDER, 0}} 620 | {FCGI_PARAMS, 1, 621 | "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "} 622 | {FCGI_PARAMS, 1, ""} 623 | {FCGI_STDIN, 1, ""} 624 | 625 | {FCGI_STDOUT, 1, "Content-type: text/html\r\n\r\n\n ... "} 626 | {FCGI_STDOUT, 1, ""} 627 | {FCGI_END_REQUEST, 1, {0, FCGI_REQUEST_COMPLETE}} 628 | ``` 629 | 630 | 2\. Similar to example 1, but this time with data on `stdin`. The Web server chooses to send the parameters using more `FCGI_PARAMS` records than before: 631 | 632 | ```c 633 | {FCGI_BEGIN_REQUEST, 1, {FCGI_RESPONDER, 0}} 634 | {FCGI_PARAMS, 1, "\013\002SERVER_PORT80\013\016SER"} 635 | {FCGI_PARAMS, 1, "VER_ADDR199.170.183.42 ... "} 636 | {FCGI_PARAMS, 1, ""} 637 | {FCGI_STDIN, 1, "quantity=100&item=3047936"} 638 | {FCGI_STDIN, 1, ""} 639 | 640 | {FCGI_STDOUT, 1, "Content-type: text/html\r\n\r\n\n ... "} 641 | {FCGI_STDOUT, 1, ""} 642 | {FCGI_END_REQUEST, 1, {0, FCGI_REQUEST_COMPLETE}} 643 | ``` 644 | 645 | 3\. Similar to example 1, but this time the application detects an error. The application logs a message to `stderr`, returns a page to the client, and returns non-zero exit status to the Web server. The application chooses to send the page using more `FCGI_STDOUT` records: 646 | 647 | ```c 648 | {FCGI_BEGIN_REQUEST, 1, {FCGI_RESPONDER, 0}} 649 | {FCGI_PARAMS, 1, 650 | "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "} 651 | {FCGI_PARAMS, 1, ""} 652 | {FCGI_STDIN, 1, ""} 653 | 654 | {FCGI_STDOUT, 1, "Content-type: text/html\r\n\r\n\n ... "} 657 | {FCGI_STDOUT, 1, ""} 658 | {FCGI_STDERR, 1, ""} 659 | {FCGI_END_REQUEST, 1, {938, FCGI_REQUEST_COMPLETE}} 660 | ``` 661 | 662 | 4\. Two instances of example 1, multiplexed onto a single connection. The first request is more difficult than the second, so the application finishes the requests out of order: 663 | 664 | ```c 665 | {FCGI_BEGIN_REQUEST, 1, {FCGI_RESPONDER, FCGI_KEEP_CONN}} 666 | {FCGI_PARAMS, 1, 667 | "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "} 668 | {FCGI_PARAMS, 1, ""} 669 | {FCGI_BEGIN_REQUEST, 2, {FCGI_RESPONDER, FCGI_KEEP_CONN}} 670 | {FCGI_PARAMS, 2, 671 | "\013\002SERVER_PORT80\013\016SERVER_ADDR199.170.183.42 ... "} 672 | {FCGI_STDIN, 1, ""} 673 | 674 | {FCGI_STDOUT, 1, "Content-type: text/html\r\n\r\n"} 675 | 676 | {FCGI_PARAMS, 2, ""} 677 | {FCGI_STDIN, 2, ""} 678 | 679 | {FCGI_STDOUT, 2, "Content-type: text/html\r\n\r\n\n ... "} 680 | {FCGI_STDOUT, 2, ""} 681 | {FCGI_END_REQUEST, 2, {0, FCGI_REQUEST_COMPLETE}} 682 | {FCGI_STDOUT, 1, "\n ... "} 683 | {FCGI_STDOUT, 1, ""} 684 | {FCGI_END_REQUEST, 1, {0, FCGI_REQUEST_COMPLETE}} 685 | ``` 686 | 687 | * * * 688 | 689 | *© Copyright 1995, 1996 Open Market, Inc. / mbrown@openmarket.com* 690 | --------------------------------------------------------------------------------