├── .gitignore ├── .travis.yml ├── CI.proj ├── Examples ├── windows-nginx-1.0.15 │ ├── conf │ │ ├── fastcgi.conf │ │ ├── fastcgi_params │ │ ├── koi-utf │ │ ├── koi-win │ │ ├── mime.types │ │ ├── nginx.conf │ │ ├── scgi_params │ │ ├── uwsgi_params │ │ └── win-utf │ ├── contrib │ │ ├── README │ │ ├── geo2nginx.pl │ │ └── unicode2nginx │ │ │ ├── koi-utf │ │ │ ├── unicode-to-nginx.pl │ │ │ └── win-utf │ ├── docs │ │ ├── CHANGES │ │ ├── CHANGES.ru │ │ ├── LICENSE │ │ ├── OpenSSL.LICENSE │ │ ├── PCRE.LICENCE │ │ ├── README │ │ └── zlib.LICENSE │ ├── html │ │ ├── 50x.html │ │ └── index.html │ └── nginx.exe └── windows-nginx-1.6.2 │ ├── conf │ ├── fastcgi.conf │ ├── fastcgi_params │ ├── koi-utf │ ├── koi-win │ ├── mime.types │ ├── nginx.conf │ ├── scgi_params │ ├── uwsgi_params │ └── win-utf │ ├── contrib │ ├── README │ ├── geo2nginx.pl │ ├── unicode2nginx │ │ ├── koi-utf │ │ ├── unicode-to-nginx.pl │ │ └── win-utf │ └── vim │ │ ├── ftdetect │ │ └── nginx.vim │ │ ├── indent │ │ └── nginx.vim │ │ └── syntax │ │ └── nginx.vim │ ├── docs │ ├── CHANGES │ ├── CHANGES.ru │ ├── LICENSE │ ├── OpenSSL.LICENSE │ ├── PCRE.LICENCE │ ├── README │ └── zlib.LICENSE │ ├── html │ ├── 50x.html │ └── index.html │ └── nginx.exe ├── FastCgi.AspNet ├── AspNetChannel.cs ├── AspNetChannelFactory.cs ├── AspNetHosting.cs ├── AspNetRequest.cs ├── FastCgi.AspNet.csproj ├── FastCgi.AspNet.key ├── FastCgi.AspNet.nuspec ├── FastCgiAspNetServer.cs ├── FastCgiWorkerRequest.cs ├── IAspNetRequestConfig.cs └── Properties │ └── AssemblyInfo.cs ├── FastCgi.Loggers.Log4Net ├── FastCgi.Loggers.Log4Net.csproj ├── FastCgi.Loggers.Log4Net.nuspec ├── Logger.cs ├── Loggerfactory.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── FastCgi.Owin ├── Constants.cs ├── FastCgi.Owin.csproj ├── FastCgi.Owin.nuspec ├── OwinChannel.cs ├── OwinChannelFactory.cs ├── OwinRequest.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── FastCgi.Server ├── AspNetRequestConfig.cs ├── Config.cs ├── FastCgi.Server.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Root │ ├── Web.config │ ├── info.aspx │ ├── test.aspx │ └── trace.aspx ├── TcpServerConfig.cs ├── app.config ├── log4net.config └── packages.config ├── FastCgi.Test ├── FastCgi.Test.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── SimpleChannel.cs ├── SimpleChannelFactory.cs ├── SimpleRequest.cs ├── app.config ├── log4net.xml └── packages.config ├── FastCgi.UnitTest ├── FastCgi.UnitTest.csproj ├── ImmutableArrayTests.cs └── Properties │ └── AssemblyInfo.cs ├── FastCgi.sln ├── FastCgi ├── FastCgi.csproj ├── FastCgi.key ├── FastCgi.nuspec ├── IFastCgiChannelFactory.cs ├── IFastCgiServer.cs ├── ILogger.cs ├── ILoggerFactory.cs ├── Properties │ └── AssemblyInfo.cs ├── Protocol │ ├── ChannelProperties.cs │ ├── Consts.cs │ ├── FastCgiChannel.cs │ ├── ILayer.cs │ ├── IRequestsRepository.cs │ ├── InputStream.cs │ ├── Message.cs │ ├── MessageBody.cs │ ├── MessageHeader.cs │ ├── NameValuePair.cs │ ├── NameValuePairCollection.cs │ ├── OutputStream.cs │ ├── Request.cs │ └── SimpleFastCgiChannel.cs ├── Repositories │ ├── RequestsRepository.cs │ ├── SingleRequestRepository.cs │ └── SyncronizedRequestsRepository.cs ├── Servers │ ├── ITcpServerConfig.cs │ ├── IisServer.cs │ ├── TcpLayer.cs │ └── TcpServer.cs └── Utils.cs ├── ImmutableArray ├── BufferManager.cs ├── IBufferManager.cs ├── ImmutableArray.cs ├── ImmutableArray.csproj ├── ImmutableArray.nuspec ├── ImmutableArrayEnumerator.cs ├── ImmutableArrayInternal.cs └── Properties │ └── AssemblyInfo.cs ├── LICENSE.txt ├── README.md ├── appveyor.yml └── stress_test.bat /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | bin 3 | obj 4 | *.suo 5 | *.user 6 | 7 | # mstest test results 8 | TestResults 9 | /Examples/windows-nginx-1.0.15/logs/access.log 10 | /Examples/windows-nginx-1.0.15/logs/error.log 11 | /Examples/windows-nginx-1.0.15/logs/nginx.pid 12 | *.userprefs 13 | *.log 14 | *.pid 15 | packages 16 | /.vs 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | install: 4 | - sudo sh -c "echo 'deb http://debian.meebey.net/experimental/mono /' >> /etc/apt/sources.list.d/mono-opt.list" 5 | - sudo apt-get update 6 | - sudo apt-get --force-yes install mono-devel mono-xbuild 7 | 8 | script: 9 | - xbuild CI.proj 10 | -------------------------------------------------------------------------------- /CI.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 |    4 |    5 |      6 |    7 | 8 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/conf/fastcgi.conf: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 3 | fastcgi_param QUERY_STRING $query_string; 4 | fastcgi_param REQUEST_METHOD $request_method; 5 | fastcgi_param CONTENT_TYPE $content_type; 6 | fastcgi_param CONTENT_LENGTH $content_length; 7 | 8 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 9 | fastcgi_param REQUEST_URI $request_uri; 10 | fastcgi_param DOCUMENT_URI $document_uri; 11 | fastcgi_param DOCUMENT_ROOT $document_root; 12 | fastcgi_param SERVER_PROTOCOL $server_protocol; 13 | 14 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 15 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 16 | 17 | fastcgi_param REMOTE_ADDR $remote_addr; 18 | fastcgi_param REMOTE_PORT $remote_port; 19 | fastcgi_param SERVER_ADDR $server_addr; 20 | fastcgi_param SERVER_PORT $server_port; 21 | fastcgi_param SERVER_NAME $server_name; 22 | 23 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 24 | fastcgi_param REDIRECT_STATUS 200; 25 | 26 | fastcgi_hide_header -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/conf/fastcgi_params: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param QUERY_STRING $query_string; 3 | fastcgi_param REQUEST_METHOD $request_method; 4 | fastcgi_param CONTENT_TYPE $content_type; 5 | fastcgi_param CONTENT_LENGTH $content_length; 6 | 7 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 8 | fastcgi_param REQUEST_URI $request_uri; 9 | fastcgi_param DOCUMENT_URI $document_uri; 10 | fastcgi_param DOCUMENT_ROOT $document_root; 11 | fastcgi_param SERVER_PROTOCOL $server_protocol; 12 | 13 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 14 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 15 | 16 | fastcgi_param REMOTE_ADDR $remote_addr; 17 | fastcgi_param REMOTE_PORT $remote_port; 18 | fastcgi_param SERVER_ADDR $server_addr; 19 | fastcgi_param SERVER_PORT $server_port; 20 | fastcgi_param SERVER_NAME $server_name; 21 | 22 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 23 | fastcgi_param REDIRECT_STATUS 200; 24 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/conf/koi-utf: -------------------------------------------------------------------------------- 1 | 2 | # This map is not a full koi8-r <> utf8 map: it does not contain 3 | # box-drawing and some other characters. Besides this map contains 4 | # several koi8-u and Byelorussian letters which are not in koi8-r. 5 | # If you need a full and standard map, use contrib/unicode2nginx/koi-utf 6 | # map instead. 7 | 8 | charset_map koi8-r utf-8 { 9 | 10 | 80 E282AC ; # euro 11 | 12 | 95 E280A2 ; # bullet 13 | 14 | 9A C2A0 ; #   15 | 16 | 9E C2B7 ; # · 17 | 18 | A3 D191 ; # small yo 19 | A4 D194 ; # small Ukrainian ye 20 | 21 | A6 D196 ; # small Ukrainian i 22 | A7 D197 ; # small Ukrainian yi 23 | 24 | AD D291 ; # small Ukrainian soft g 25 | AE D19E ; # small Byelorussian short u 26 | 27 | B0 C2B0 ; # ° 28 | 29 | B3 D081 ; # capital YO 30 | B4 D084 ; # capital Ukrainian YE 31 | 32 | B6 D086 ; # capital Ukrainian I 33 | B7 D087 ; # capital Ukrainian YI 34 | 35 | B9 E28496 ; # numero sign 36 | 37 | BD D290 ; # capital Ukrainian soft G 38 | BE D18E ; # capital Byelorussian short U 39 | 40 | BF C2A9 ; # (C) 41 | 42 | C0 D18E ; # small yu 43 | C1 D0B0 ; # small a 44 | C2 D0B1 ; # small b 45 | C3 D186 ; # small ts 46 | C4 D0B4 ; # small d 47 | C5 D0B5 ; # small ye 48 | C6 D184 ; # small f 49 | C7 D0B3 ; # small g 50 | C8 D185 ; # small kh 51 | C9 D0B8 ; # small i 52 | CA D0B9 ; # small j 53 | CB D0BA ; # small k 54 | CC D0BB ; # small l 55 | CD D0BC ; # small m 56 | CE D0BD ; # small n 57 | CF D0BE ; # small o 58 | 59 | D0 D0BF ; # small p 60 | D1 D18F ; # small ya 61 | D2 D180 ; # small r 62 | D3 D181 ; # small s 63 | D4 D182 ; # small t 64 | D5 D183 ; # small u 65 | D6 D0B6 ; # small zh 66 | D7 D0B2 ; # small v 67 | D8 D18C ; # small soft sign 68 | D9 D18B ; # small y 69 | DA D0B7 ; # small z 70 | DB D188 ; # small sh 71 | DC D18D ; # small e 72 | DD D189 ; # small shch 73 | DE D187 ; # small ch 74 | DF D18A ; # small hard sign 75 | 76 | E0 D0AE ; # capital YU 77 | E1 D090 ; # capital A 78 | E2 D091 ; # capital B 79 | E3 D0A6 ; # capital TS 80 | E4 D094 ; # capital D 81 | E5 D095 ; # capital YE 82 | E6 D0A4 ; # capital F 83 | E7 D093 ; # capital G 84 | E8 D0A5 ; # capital KH 85 | E9 D098 ; # capital I 86 | EA D099 ; # capital J 87 | EB D09A ; # capital K 88 | EC D09B ; # capital L 89 | ED D09C ; # capital M 90 | EE D09D ; # capital N 91 | EF D09E ; # capital O 92 | 93 | F0 D09F ; # capital P 94 | F1 D0AF ; # capital YA 95 | F2 D0A0 ; # capital R 96 | F3 D0A1 ; # capital S 97 | F4 D0A2 ; # capital T 98 | F5 D0A3 ; # capital U 99 | F6 D096 ; # capital ZH 100 | F7 D092 ; # capital V 101 | F8 D0AC ; # capital soft sign 102 | F9 D0AB ; # capital Y 103 | FA D097 ; # capital Z 104 | FB D0A8 ; # capital SH 105 | FC D0AD ; # capital E 106 | FD D0A9 ; # capital SHCH 107 | FE D0A7 ; # capital CH 108 | FF D0AA ; # capital hard sign 109 | } 110 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/conf/koi-win: -------------------------------------------------------------------------------- 1 | 2 | charset_map koi8-r windows-1251 { 3 | 4 | 80 88 ; # euro 5 | 6 | 95 95 ; # bullet 7 | 8 | 9A A0 ; #   9 | 10 | 9E B7 ; # · 11 | 12 | A3 B8 ; # small yo 13 | A4 BA ; # small Ukrainian ye 14 | 15 | A6 B3 ; # small Ukrainian i 16 | A7 BF ; # small Ukrainian yi 17 | 18 | AD B4 ; # small Ukrainian soft g 19 | AE A2 ; # small Byelorussian short u 20 | 21 | B0 B0 ; # ° 22 | 23 | B3 A8 ; # capital YO 24 | B4 AA ; # capital Ukrainian YE 25 | 26 | B6 B2 ; # capital Ukrainian I 27 | B7 AF ; # capital Ukrainian YI 28 | 29 | B9 B9 ; # numero sign 30 | 31 | BD A5 ; # capital Ukrainian soft G 32 | BE A1 ; # capital Byelorussian short U 33 | 34 | BF A9 ; # (C) 35 | 36 | C0 FE ; # small yu 37 | C1 E0 ; # small a 38 | C2 E1 ; # small b 39 | C3 F6 ; # small ts 40 | C4 E4 ; # small d 41 | C5 E5 ; # small ye 42 | C6 F4 ; # small f 43 | C7 E3 ; # small g 44 | C8 F5 ; # small kh 45 | C9 E8 ; # small i 46 | CA E9 ; # small j 47 | CB EA ; # small k 48 | CC EB ; # small l 49 | CD EC ; # small m 50 | CE ED ; # small n 51 | CF EE ; # small o 52 | 53 | D0 EF ; # small p 54 | D1 FF ; # small ya 55 | D2 F0 ; # small r 56 | D3 F1 ; # small s 57 | D4 F2 ; # small t 58 | D5 F3 ; # small u 59 | D6 E6 ; # small zh 60 | D7 E2 ; # small v 61 | D8 FC ; # small soft sign 62 | D9 FB ; # small y 63 | DA E7 ; # small z 64 | DB F8 ; # small sh 65 | DC FD ; # small e 66 | DD F9 ; # small shch 67 | DE F7 ; # small ch 68 | DF FA ; # small hard sign 69 | 70 | E0 DE ; # capital YU 71 | E1 C0 ; # capital A 72 | E2 C1 ; # capital B 73 | E3 D6 ; # capital TS 74 | E4 C4 ; # capital D 75 | E5 C5 ; # capital YE 76 | E6 D4 ; # capital F 77 | E7 C3 ; # capital G 78 | E8 D5 ; # capital KH 79 | E9 C8 ; # capital I 80 | EA C9 ; # capital J 81 | EB CA ; # capital K 82 | EC CB ; # capital L 83 | ED CC ; # capital M 84 | EE CD ; # capital N 85 | EF CE ; # capital O 86 | 87 | F0 CF ; # capital P 88 | F1 DF ; # capital YA 89 | F2 D0 ; # capital R 90 | F3 D1 ; # capital S 91 | F4 D2 ; # capital T 92 | F5 D3 ; # capital U 93 | F6 C6 ; # capital ZH 94 | F7 C2 ; # capital V 95 | F8 DC ; # capital soft sign 96 | F9 DB ; # capital Y 97 | FA C7 ; # capital Z 98 | FB D8 ; # capital SH 99 | FC DD ; # capital E 100 | FD D9 ; # capital SHCH 101 | FE D7 ; # capital CH 102 | FF DA ; # capital hard sign 103 | } 104 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/conf/mime.types: -------------------------------------------------------------------------------- 1 | 2 | types { 3 | text/html html htm shtml; 4 | text/css css; 5 | text/xml xml; 6 | image/gif gif; 7 | image/jpeg jpeg jpg; 8 | application/x-javascript js; 9 | application/atom+xml atom; 10 | application/rss+xml rss; 11 | 12 | text/mathml mml; 13 | text/plain txt; 14 | text/vnd.sun.j2me.app-descriptor jad; 15 | text/vnd.wap.wml wml; 16 | text/x-component htc; 17 | 18 | image/png png; 19 | image/tiff tif tiff; 20 | image/vnd.wap.wbmp wbmp; 21 | image/x-icon ico; 22 | image/x-jng jng; 23 | image/x-ms-bmp bmp; 24 | image/svg+xml svg svgz; 25 | image/webp webp; 26 | 27 | application/java-archive jar war ear; 28 | application/mac-binhex40 hqx; 29 | application/msword doc; 30 | application/pdf pdf; 31 | application/postscript ps eps ai; 32 | application/rtf rtf; 33 | application/vnd.ms-excel xls; 34 | application/vnd.ms-powerpoint ppt; 35 | application/vnd.wap.wmlc wmlc; 36 | application/vnd.google-earth.kml+xml kml; 37 | application/vnd.google-earth.kmz kmz; 38 | application/x-7z-compressed 7z; 39 | application/x-cocoa cco; 40 | application/x-java-archive-diff jardiff; 41 | application/x-java-jnlp-file jnlp; 42 | application/x-makeself run; 43 | application/x-perl pl pm; 44 | application/x-pilot prc pdb; 45 | application/x-rar-compressed rar; 46 | application/x-redhat-package-manager rpm; 47 | application/x-sea sea; 48 | application/x-shockwave-flash swf; 49 | application/x-stuffit sit; 50 | application/x-tcl tcl tk; 51 | application/x-x509-ca-cert der pem crt; 52 | application/x-xpinstall xpi; 53 | application/xhtml+xml xhtml; 54 | application/zip zip; 55 | 56 | application/octet-stream bin exe dll; 57 | application/octet-stream deb; 58 | application/octet-stream dmg; 59 | application/octet-stream eot; 60 | application/octet-stream iso img; 61 | application/octet-stream msi msp msm; 62 | 63 | audio/midi mid midi kar; 64 | audio/mpeg mp3; 65 | audio/ogg ogg; 66 | audio/x-m4a m4a; 67 | audio/x-realaudio ra; 68 | 69 | video/3gpp 3gpp 3gp; 70 | video/mp4 mp4; 71 | video/mpeg mpeg mpg; 72 | video/quicktime mov; 73 | video/webm webm; 74 | video/x-flv flv; 75 | video/x-m4v m4v; 76 | video/x-mng mng; 77 | video/x-ms-asf asx asf; 78 | video/x-ms-wmv wmv; 79 | video/x-msvideo avi; 80 | } 81 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/conf/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | #user nobody; 3 | worker_processes 1; 4 | 5 | #error_log logs/error.log; 6 | #error_log logs/error.log notice; 7 | #error_log logs/error.log info; 8 | 9 | #pid logs/nginx.pid; 10 | 11 | 12 | events { 13 | worker_connections 1024; 14 | } 15 | 16 | 17 | http { 18 | include mime.types; 19 | default_type application/octet-stream; 20 | 21 | #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 22 | # '$status $body_bytes_sent "$http_referer" ' 23 | # '"$http_user_agent" "$http_x_forwarded_for"'; 24 | 25 | #access_log logs/access.log main; 26 | 27 | sendfile on; 28 | #tcp_nopush on; 29 | 30 | #keepalive_timeout 0; 31 | keepalive_timeout 65; 32 | 33 | #gzip on; 34 | 35 | server { 36 | listen 8082; 37 | server_name localhost; 38 | 39 | #charset koi8-r; 40 | 41 | #access_log logs/host.access.log main; 42 | 43 | location / { 44 | root html; 45 | index index.html index.htm; 46 | } 47 | 48 | #error_page 404 /404.html; 49 | 50 | # redirect server error pages to the static page /50x.html 51 | # 52 | error_page 500 502 503 504 /50x.html; 53 | location = /50x.html { 54 | root html; 55 | } 56 | 57 | # pass the ASPX pages to FastCGI server listening on 127.0.0.1:9000 58 | 59 | location ~ ^.+\.aspx { 60 | root html; 61 | fastcgi_pass 127.0.0.1:9000; 62 | fastcgi_index Default.aspx; 63 | 64 | fastcgi_split_path_info ^((?U).+\.aspx)(/?.+)$; 65 | fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; 66 | fastcgi_param PATH_INFO $fastcgi_path_info; 67 | fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 68 | include fastcgi_params; 69 | } 70 | 71 | location /cgi/ { 72 | root html; 73 | fastcgi_pass 127.0.0.1:9000; 74 | fastcgi_index Default.aspx; 75 | 76 | fastcgi_split_path_info ^(.*cgi)(/.*)$; 77 | fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; 78 | fastcgi_param PATH_INFO $fastcgi_path_info; 79 | fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 80 | include fastcgi_params; 81 | } 82 | 83 | # deny access to .htaccess files, if Apache's document root 84 | # concurs with nginx's one 85 | # 86 | #location ~ /\.ht { 87 | # deny all; 88 | #} 89 | } 90 | 91 | 92 | # another virtual host using mix of IP-, name-, and port-based configuration 93 | # 94 | #server { 95 | # listen 8000; 96 | # listen somename:8080; 97 | # server_name somename alias another.alias; 98 | 99 | # location / { 100 | # root html; 101 | # index index.html index.htm; 102 | # } 103 | #} 104 | 105 | 106 | # HTTPS server 107 | # 108 | #server { 109 | # listen 443; 110 | # server_name localhost; 111 | 112 | # ssl on; 113 | # ssl_certificate cert.pem; 114 | # ssl_certificate_key cert.key; 115 | 116 | # ssl_session_timeout 5m; 117 | 118 | # ssl_protocols SSLv2 SSLv3 TLSv1; 119 | # ssl_ciphers HIGH:!aNULL:!MD5; 120 | # ssl_prefer_server_ciphers on; 121 | 122 | # location / { 123 | # root html; 124 | # index index.html index.htm; 125 | # } 126 | #} 127 | 128 | } 129 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/conf/scgi_params: -------------------------------------------------------------------------------- 1 | 2 | scgi_param REQUEST_METHOD $request_method; 3 | scgi_param REQUEST_URI $request_uri; 4 | scgi_param QUERY_STRING $query_string; 5 | scgi_param CONTENT_TYPE $content_type; 6 | 7 | scgi_param DOCUMENT_URI $document_uri; 8 | scgi_param DOCUMENT_ROOT $document_root; 9 | scgi_param SCGI 1; 10 | scgi_param SERVER_PROTOCOL $server_protocol; 11 | 12 | scgi_param REMOTE_ADDR $remote_addr; 13 | scgi_param REMOTE_PORT $remote_port; 14 | scgi_param SERVER_PORT $server_port; 15 | scgi_param SERVER_NAME $server_name; 16 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/conf/uwsgi_params: -------------------------------------------------------------------------------- 1 | 2 | uwsgi_param QUERY_STRING $query_string; 3 | uwsgi_param REQUEST_METHOD $request_method; 4 | uwsgi_param CONTENT_TYPE $content_type; 5 | uwsgi_param CONTENT_LENGTH $content_length; 6 | 7 | uwsgi_param REQUEST_URI $request_uri; 8 | uwsgi_param PATH_INFO $document_uri; 9 | uwsgi_param DOCUMENT_ROOT $document_root; 10 | uwsgi_param SERVER_PROTOCOL $server_protocol; 11 | 12 | uwsgi_param REMOTE_ADDR $remote_addr; 13 | uwsgi_param REMOTE_PORT $remote_port; 14 | uwsgi_param SERVER_PORT $server_port; 15 | uwsgi_param SERVER_NAME $server_name; 16 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/conf/win-utf: -------------------------------------------------------------------------------- 1 | 2 | # This map is not a full windows-1251 <> utf8 map: it does not 3 | # contain Serbian and Macedonian letters. If you need a full map, 4 | # use contrib/unicode2nginx/win-utf map instead. 5 | 6 | charset_map windows-1251 utf-8 { 7 | 8 | 82 E2809A ; # single low-9 quotation mark 9 | 10 | 84 E2809E ; # double low-9 quotation mark 11 | 85 E280A6 ; # ellipsis 12 | 86 E280A0 ; # dagger 13 | 87 E280A1 ; # double dagger 14 | 88 E282AC ; # euro 15 | 89 E280B0 ; # per mille 16 | 17 | 91 E28098 ; # left single quotation mark 18 | 92 E28099 ; # right single quotation mark 19 | 93 E2809C ; # left double quotation mark 20 | 94 E2809D ; # right double quotation mark 21 | 95 E280A2 ; # bullet 22 | 96 E28093 ; # en dash 23 | 97 E28094 ; # em dash 24 | 25 | 99 E284A2 ; # trade mark sign 26 | 27 | A0 C2A0 ; #   28 | A1 D18E ; # capital Byelorussian short U 29 | A2 D19E ; # small Byelorussian short u 30 | 31 | A4 C2A4 ; # currency sign 32 | A5 D290 ; # capital Ukrainian soft G 33 | A6 C2A6 ; # borken bar 34 | A7 C2A7 ; # section sign 35 | A8 D081 ; # capital YO 36 | A9 C2A9 ; # (C) 37 | AA D084 ; # capital Ukrainian YE 38 | AB C2AB ; # left-pointing double angle quotation mark 39 | AC C2AC ; # not sign 40 | AD C2AD ; # soft hypen 41 | AE C2AE ; # (R) 42 | AF D087 ; # capital Ukrainian YI 43 | 44 | B0 C2B0 ; # ° 45 | B1 C2B1 ; # plus-minus sign 46 | B2 D086 ; # capital Ukrainian I 47 | B3 D196 ; # small Ukrainian i 48 | B4 D291 ; # small Ukrainian soft g 49 | B5 C2B5 ; # micro sign 50 | B6 C2B6 ; # pilcrow sign 51 | B7 C2B7 ; # · 52 | B8 D191 ; # small yo 53 | B9 E28496 ; # numero sign 54 | BA D194 ; # small Ukrainian ye 55 | BB C2BB ; # right-pointing double angle quotation mark 56 | 57 | BF D197 ; # small Ukrainian yi 58 | 59 | C0 D090 ; # capital A 60 | C1 D091 ; # capital B 61 | C2 D092 ; # capital V 62 | C3 D093 ; # capital G 63 | C4 D094 ; # capital D 64 | C5 D095 ; # capital YE 65 | C6 D096 ; # capital ZH 66 | C7 D097 ; # capital Z 67 | C8 D098 ; # capital I 68 | C9 D099 ; # capital J 69 | CA D09A ; # capital K 70 | CB D09B ; # capital L 71 | CC D09C ; # capital M 72 | CD D09D ; # capital N 73 | CE D09E ; # capital O 74 | CF D09F ; # capital P 75 | 76 | D0 D0A0 ; # capital R 77 | D1 D0A1 ; # capital S 78 | D2 D0A2 ; # capital T 79 | D3 D0A3 ; # capital U 80 | D4 D0A4 ; # capital F 81 | D5 D0A5 ; # capital KH 82 | D6 D0A6 ; # capital TS 83 | D7 D0A7 ; # capital CH 84 | D8 D0A8 ; # capital SH 85 | D9 D0A9 ; # capital SHCH 86 | DA D0AA ; # capital hard sign 87 | DB D0AB ; # capital Y 88 | DC D0AC ; # capital soft sign 89 | DD D0AD ; # capital E 90 | DE D0AE ; # capital YU 91 | DF D0AF ; # capital YA 92 | 93 | E0 D0B0 ; # small a 94 | E1 D0B1 ; # small b 95 | E2 D0B2 ; # small v 96 | E3 D0B3 ; # small g 97 | E4 D0B4 ; # small d 98 | E5 D0B5 ; # small ye 99 | E6 D0B6 ; # small zh 100 | E7 D0B7 ; # small z 101 | E8 D0B8 ; # small i 102 | E9 D0B9 ; # small j 103 | EA D0BA ; # small k 104 | EB D0BB ; # small l 105 | EC D0BC ; # small m 106 | ED D0BD ; # small n 107 | EE D0BE ; # small o 108 | EF D0BF ; # small p 109 | 110 | F0 D180 ; # small r 111 | F1 D181 ; # small s 112 | F2 D182 ; # small t 113 | F3 D183 ; # small u 114 | F4 D184 ; # small f 115 | F5 D185 ; # small kh 116 | F6 D186 ; # small ts 117 | F7 D187 ; # small ch 118 | F8 D188 ; # small sh 119 | F9 D189 ; # small shch 120 | FA D18A ; # small hard sign 121 | FB D18B ; # small y 122 | FC D18C ; # small soft sign 123 | FD D18D ; # small e 124 | FE D18E ; # small yu 125 | FF D18F ; # small ya 126 | } 127 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/contrib/README: -------------------------------------------------------------------------------- 1 | 2 | geo2nginx.pl by Andrei Nigmatulin 3 | 4 | The perl script to convert CSV geoip database ( free download 5 | at http://www.maxmind.com/app/geoip_country ) to format, suitable 6 | for use by the ngx_http_geo_module. 7 | 8 | 9 | unicode2nginx by Maxim Dounin 10 | 11 | The perl script to convert unicode mappings ( available 12 | at http://www.unicode.org/Public/MAPPINGS/ ) to the nginx 13 | configuration file format. 14 | Two generated full maps for windows-1251 and koi8-r. 15 | 16 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/contrib/geo2nginx.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # (c) Andrei Nigmatulin, 2005 4 | # 5 | # this script provided "as is", without any warranties. use it at your own risk. 6 | # 7 | # special thanx to Andrew Sitnikov for perl port 8 | # 9 | # this script converts CSV geoip database (free download at http://www.maxmind.com/app/geoip_country) 10 | # to format, suitable for use with nginx_http_geo module (http://sysoev.ru/nginx) 11 | # 12 | # for example, line with ip range 13 | # 14 | # "62.16.68.0","62.16.127.255","1041253376","1041268735","RU","Russian Federation" 15 | # 16 | # will be converted to four subnetworks: 17 | # 18 | # 62.16.68.0/22 RU; 19 | # 62.16.72.0/21 RU; 20 | # 62.16.80.0/20 RU; 21 | # 62.16.96.0/19 RU; 22 | 23 | 24 | use warnings; 25 | use strict; 26 | 27 | while( ){ 28 | if (/"[^"]+","[^"]+","([^"]+)","([^"]+)","([^"]+)"/){ 29 | print_subnets($1, $2, $3); 30 | } 31 | } 32 | 33 | sub print_subnets { 34 | my ($a1, $a2, $c) = @_; 35 | my $l; 36 | while ($a1 <= $a2) { 37 | for ($l = 0; ($a1 & (1 << $l)) == 0 && ($a1 + ((1 << ($l + 1)) - 1)) <= $a2; $l++){}; 38 | print long2ip($a1) . "/" . (32 - $l) . " " . $c . ";\n"; 39 | $a1 += (1 << $l); 40 | } 41 | } 42 | 43 | sub long2ip { 44 | my $ip = shift; 45 | 46 | my $str = 0; 47 | 48 | $str = ($ip & 255); 49 | 50 | $ip >>= 8; 51 | $str = ($ip & 255).".$str"; 52 | 53 | $ip >>= 8; 54 | $str = ($ip & 255).".$str"; 55 | 56 | $ip >>= 8; 57 | $str = ($ip & 255).".$str"; 58 | } 59 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/contrib/unicode2nginx/unicode-to-nginx.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # Convert unicode mappings to nginx configuration file format. 4 | 5 | # You may find useful mappings in various places, including 6 | # unicode.org official site: 7 | # 8 | # http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT 9 | # http://www.unicode.org/Public/MAPPINGS/VENDORS/MISC/KOI8-R.TXT 10 | 11 | # Needs perl 5.6 or later. 12 | 13 | # Written by Maxim Dounin, mdounin@rambler-co.ru 14 | 15 | ############################################################################### 16 | 17 | require 5.006; 18 | 19 | while (<>) { 20 | # Skip comments and empty lines 21 | 22 | next if /^#/; 23 | next if /^\s*$/; 24 | chomp; 25 | 26 | # Convert mappings 27 | 28 | if (/^\s*0x(..)\s*0x(....)\s*(#.*)/) { 29 | # Mapping "#" 30 | my $cs_code = $1; 31 | my $un_code = $2; 32 | my $un_name = $3; 33 | 34 | # Produce UTF-8 sequence from character code; 35 | 36 | my $un_utf8 = join('', map { sprintf("%02X", $_) } unpack("C*", pack("U", hex($un_code)))); 37 | 38 | print " $cs_code $un_utf8 ; $un_name\n"; 39 | 40 | } else { 41 | warn "Unrecognized line: '$_'"; 42 | } 43 | } 44 | 45 | ############################################################################### 46 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/docs/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2012 Igor Sysoev 3 | * Copyright (C) 2011,2012 Nginx, Inc. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/docs/PCRE.LICENCE: -------------------------------------------------------------------------------- 1 | PCRE LICENCE 2 | ------------ 3 | 4 | PCRE is a library of functions to support regular expressions whose syntax 5 | and semantics are as close as possible to those of the Perl 5 language. 6 | 7 | Release 8 of PCRE is distributed under the terms of the "BSD" licence, as 8 | specified below. The documentation for PCRE, supplied in the "doc" 9 | directory, is distributed under the same terms as the software itself. 10 | 11 | The basic library functions are written in C and are freestanding. Also 12 | included in the distribution is a set of C++ wrapper functions, and a 13 | just-in-time compiler that can be used to optimize pattern matching. These 14 | are both optional features that can be omitted when the library is built. 15 | 16 | 17 | THE BASIC LIBRARY FUNCTIONS 18 | --------------------------- 19 | 20 | Written by: Philip Hazel 21 | Email local part: ph10 22 | Email domain: cam.ac.uk 23 | 24 | University of Cambridge Computing Service, 25 | Cambridge, England. 26 | 27 | Copyright (c) 1997-2012 University of Cambridge 28 | All rights reserved. 29 | 30 | 31 | PCRE JUST-IN-TIME COMPILATION SUPPORT 32 | ------------------------------------- 33 | 34 | Written by: Zoltan Herczeg 35 | Email local part: hzmester 36 | Emain domain: freemail.hu 37 | 38 | Copyright(c) 2010-2012 Zoltan Herczeg 39 | All rights reserved. 40 | 41 | 42 | STACK-LESS JUST-IN-TIME COMPILER 43 | -------------------------------- 44 | 45 | Written by: Zoltan Herczeg 46 | Email local part: hzmester 47 | Emain domain: freemail.hu 48 | 49 | Copyright(c) 2009-2012 Zoltan Herczeg 50 | All rights reserved. 51 | 52 | 53 | THE C++ WRAPPER FUNCTIONS 54 | ------------------------- 55 | 56 | Contributed by: Google Inc. 57 | 58 | Copyright (c) 2007-2012, Google Inc. 59 | All rights reserved. 60 | 61 | 62 | THE "BSD" LICENCE 63 | ----------------- 64 | 65 | Redistribution and use in source and binary forms, with or without 66 | modification, are permitted provided that the following conditions are met: 67 | 68 | * Redistributions of source code must retain the above copyright notice, 69 | this list of conditions and the following disclaimer. 70 | 71 | * Redistributions in binary form must reproduce the above copyright 72 | notice, this list of conditions and the following disclaimer in the 73 | documentation and/or other materials provided with the distribution. 74 | 75 | * Neither the name of the University of Cambridge nor the name of Google 76 | Inc. nor the names of their contributors may be used to endorse or 77 | promote products derived from this software without specific prior 78 | written permission. 79 | 80 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 81 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 82 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 83 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 84 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 85 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 86 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 87 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 88 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 89 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 90 | POSSIBILITY OF SUCH DAMAGE. 91 | 92 | End 93 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/docs/README: -------------------------------------------------------------------------------- 1 | 2 | Documentation is available at http://nginx.org 3 | 4 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/docs/zlib.LICENSE: -------------------------------------------------------------------------------- 1 | (C) 1995-2010 Jean-loup Gailly and Mark Adler 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | 19 | Jean-loup Gailly Mark Adler 20 | jloup@gzip.org madler@alumni.caltech.edu 21 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/html/50x.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | The page is temporarily unavailable 4 | 7 | 8 | 9 | 10 | 11 | 15 | 16 |
12 | The page you are looking for is temporarily unavailable.
13 | Please try again later. 14 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Welcome to nginx! 4 | 5 | 6 |

Welcome to nginx!

7 | 8 | 9 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.0.15/nginx.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gigi81/sharpfastcgi/e5aeead9f9be13e423067de2de876ba9821f81b2/Examples/windows-nginx-1.0.15/nginx.exe -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/conf/fastcgi.conf: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 3 | fastcgi_param QUERY_STRING $query_string; 4 | fastcgi_param REQUEST_METHOD $request_method; 5 | fastcgi_param CONTENT_TYPE $content_type; 6 | fastcgi_param CONTENT_LENGTH $content_length; 7 | 8 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 9 | fastcgi_param REQUEST_URI $request_uri; 10 | fastcgi_param DOCUMENT_URI $document_uri; 11 | fastcgi_param DOCUMENT_ROOT $document_root; 12 | fastcgi_param SERVER_PROTOCOL $server_protocol; 13 | fastcgi_param HTTPS $https if_not_empty; 14 | 15 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 16 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 17 | 18 | fastcgi_param REMOTE_ADDR $remote_addr; 19 | fastcgi_param REMOTE_PORT $remote_port; 20 | fastcgi_param SERVER_ADDR $server_addr; 21 | fastcgi_param SERVER_PORT $server_port; 22 | fastcgi_param SERVER_NAME $server_name; 23 | 24 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 25 | fastcgi_param REDIRECT_STATUS 200; 26 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/conf/fastcgi_params: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param QUERY_STRING $query_string; 3 | fastcgi_param REQUEST_METHOD $request_method; 4 | fastcgi_param CONTENT_TYPE $content_type; 5 | fastcgi_param CONTENT_LENGTH $content_length; 6 | 7 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 8 | fastcgi_param REQUEST_URI $request_uri; 9 | fastcgi_param DOCUMENT_URI $document_uri; 10 | fastcgi_param DOCUMENT_ROOT $document_root; 11 | fastcgi_param SERVER_PROTOCOL $server_protocol; 12 | fastcgi_param HTTPS $https if_not_empty; 13 | 14 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 15 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 16 | 17 | fastcgi_param REMOTE_ADDR $remote_addr; 18 | fastcgi_param REMOTE_PORT $remote_port; 19 | fastcgi_param SERVER_ADDR $server_addr; 20 | fastcgi_param SERVER_PORT $server_port; 21 | fastcgi_param SERVER_NAME $server_name; 22 | 23 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 24 | fastcgi_param REDIRECT_STATUS 200; 25 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/conf/koi-utf: -------------------------------------------------------------------------------- 1 | 2 | # This map is not a full koi8-r <> utf8 map: it does not contain 3 | # box-drawing and some other characters. Besides this map contains 4 | # several koi8-u and Byelorussian letters which are not in koi8-r. 5 | # If you need a full and standard map, use contrib/unicode2nginx/koi-utf 6 | # map instead. 7 | 8 | charset_map koi8-r utf-8 { 9 | 10 | 80 E282AC ; # euro 11 | 12 | 95 E280A2 ; # bullet 13 | 14 | 9A C2A0 ; #   15 | 16 | 9E C2B7 ; # · 17 | 18 | A3 D191 ; # small yo 19 | A4 D194 ; # small Ukrainian ye 20 | 21 | A6 D196 ; # small Ukrainian i 22 | A7 D197 ; # small Ukrainian yi 23 | 24 | AD D291 ; # small Ukrainian soft g 25 | AE D19E ; # small Byelorussian short u 26 | 27 | B0 C2B0 ; # ° 28 | 29 | B3 D081 ; # capital YO 30 | B4 D084 ; # capital Ukrainian YE 31 | 32 | B6 D086 ; # capital Ukrainian I 33 | B7 D087 ; # capital Ukrainian YI 34 | 35 | B9 E28496 ; # numero sign 36 | 37 | BD D290 ; # capital Ukrainian soft G 38 | BE D18E ; # capital Byelorussian short U 39 | 40 | BF C2A9 ; # (C) 41 | 42 | C0 D18E ; # small yu 43 | C1 D0B0 ; # small a 44 | C2 D0B1 ; # small b 45 | C3 D186 ; # small ts 46 | C4 D0B4 ; # small d 47 | C5 D0B5 ; # small ye 48 | C6 D184 ; # small f 49 | C7 D0B3 ; # small g 50 | C8 D185 ; # small kh 51 | C9 D0B8 ; # small i 52 | CA D0B9 ; # small j 53 | CB D0BA ; # small k 54 | CC D0BB ; # small l 55 | CD D0BC ; # small m 56 | CE D0BD ; # small n 57 | CF D0BE ; # small o 58 | 59 | D0 D0BF ; # small p 60 | D1 D18F ; # small ya 61 | D2 D180 ; # small r 62 | D3 D181 ; # small s 63 | D4 D182 ; # small t 64 | D5 D183 ; # small u 65 | D6 D0B6 ; # small zh 66 | D7 D0B2 ; # small v 67 | D8 D18C ; # small soft sign 68 | D9 D18B ; # small y 69 | DA D0B7 ; # small z 70 | DB D188 ; # small sh 71 | DC D18D ; # small e 72 | DD D189 ; # small shch 73 | DE D187 ; # small ch 74 | DF D18A ; # small hard sign 75 | 76 | E0 D0AE ; # capital YU 77 | E1 D090 ; # capital A 78 | E2 D091 ; # capital B 79 | E3 D0A6 ; # capital TS 80 | E4 D094 ; # capital D 81 | E5 D095 ; # capital YE 82 | E6 D0A4 ; # capital F 83 | E7 D093 ; # capital G 84 | E8 D0A5 ; # capital KH 85 | E9 D098 ; # capital I 86 | EA D099 ; # capital J 87 | EB D09A ; # capital K 88 | EC D09B ; # capital L 89 | ED D09C ; # capital M 90 | EE D09D ; # capital N 91 | EF D09E ; # capital O 92 | 93 | F0 D09F ; # capital P 94 | F1 D0AF ; # capital YA 95 | F2 D0A0 ; # capital R 96 | F3 D0A1 ; # capital S 97 | F4 D0A2 ; # capital T 98 | F5 D0A3 ; # capital U 99 | F6 D096 ; # capital ZH 100 | F7 D092 ; # capital V 101 | F8 D0AC ; # capital soft sign 102 | F9 D0AB ; # capital Y 103 | FA D097 ; # capital Z 104 | FB D0A8 ; # capital SH 105 | FC D0AD ; # capital E 106 | FD D0A9 ; # capital SHCH 107 | FE D0A7 ; # capital CH 108 | FF D0AA ; # capital hard sign 109 | } 110 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/conf/koi-win: -------------------------------------------------------------------------------- 1 | 2 | charset_map koi8-r windows-1251 { 3 | 4 | 80 88 ; # euro 5 | 6 | 95 95 ; # bullet 7 | 8 | 9A A0 ; #   9 | 10 | 9E B7 ; # · 11 | 12 | A3 B8 ; # small yo 13 | A4 BA ; # small Ukrainian ye 14 | 15 | A6 B3 ; # small Ukrainian i 16 | A7 BF ; # small Ukrainian yi 17 | 18 | AD B4 ; # small Ukrainian soft g 19 | AE A2 ; # small Byelorussian short u 20 | 21 | B0 B0 ; # ° 22 | 23 | B3 A8 ; # capital YO 24 | B4 AA ; # capital Ukrainian YE 25 | 26 | B6 B2 ; # capital Ukrainian I 27 | B7 AF ; # capital Ukrainian YI 28 | 29 | B9 B9 ; # numero sign 30 | 31 | BD A5 ; # capital Ukrainian soft G 32 | BE A1 ; # capital Byelorussian short U 33 | 34 | BF A9 ; # (C) 35 | 36 | C0 FE ; # small yu 37 | C1 E0 ; # small a 38 | C2 E1 ; # small b 39 | C3 F6 ; # small ts 40 | C4 E4 ; # small d 41 | C5 E5 ; # small ye 42 | C6 F4 ; # small f 43 | C7 E3 ; # small g 44 | C8 F5 ; # small kh 45 | C9 E8 ; # small i 46 | CA E9 ; # small j 47 | CB EA ; # small k 48 | CC EB ; # small l 49 | CD EC ; # small m 50 | CE ED ; # small n 51 | CF EE ; # small o 52 | 53 | D0 EF ; # small p 54 | D1 FF ; # small ya 55 | D2 F0 ; # small r 56 | D3 F1 ; # small s 57 | D4 F2 ; # small t 58 | D5 F3 ; # small u 59 | D6 E6 ; # small zh 60 | D7 E2 ; # small v 61 | D8 FC ; # small soft sign 62 | D9 FB ; # small y 63 | DA E7 ; # small z 64 | DB F8 ; # small sh 65 | DC FD ; # small e 66 | DD F9 ; # small shch 67 | DE F7 ; # small ch 68 | DF FA ; # small hard sign 69 | 70 | E0 DE ; # capital YU 71 | E1 C0 ; # capital A 72 | E2 C1 ; # capital B 73 | E3 D6 ; # capital TS 74 | E4 C4 ; # capital D 75 | E5 C5 ; # capital YE 76 | E6 D4 ; # capital F 77 | E7 C3 ; # capital G 78 | E8 D5 ; # capital KH 79 | E9 C8 ; # capital I 80 | EA C9 ; # capital J 81 | EB CA ; # capital K 82 | EC CB ; # capital L 83 | ED CC ; # capital M 84 | EE CD ; # capital N 85 | EF CE ; # capital O 86 | 87 | F0 CF ; # capital P 88 | F1 DF ; # capital YA 89 | F2 D0 ; # capital R 90 | F3 D1 ; # capital S 91 | F4 D2 ; # capital T 92 | F5 D3 ; # capital U 93 | F6 C6 ; # capital ZH 94 | F7 C2 ; # capital V 95 | F8 DC ; # capital soft sign 96 | F9 DB ; # capital Y 97 | FA C7 ; # capital Z 98 | FB D8 ; # capital SH 99 | FC DD ; # capital E 100 | FD D9 ; # capital SHCH 101 | FE D7 ; # capital CH 102 | FF DA ; # capital hard sign 103 | } 104 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/conf/mime.types: -------------------------------------------------------------------------------- 1 | 2 | types { 3 | text/html html htm shtml; 4 | text/css css; 5 | text/xml xml; 6 | image/gif gif; 7 | image/jpeg jpeg jpg; 8 | application/javascript js; 9 | application/atom+xml atom; 10 | application/rss+xml rss; 11 | 12 | text/mathml mml; 13 | text/plain txt; 14 | text/vnd.sun.j2me.app-descriptor jad; 15 | text/vnd.wap.wml wml; 16 | text/x-component htc; 17 | 18 | image/png png; 19 | image/tiff tif tiff; 20 | image/vnd.wap.wbmp wbmp; 21 | image/x-icon ico; 22 | image/x-jng jng; 23 | image/x-ms-bmp bmp; 24 | image/svg+xml svg svgz; 25 | image/webp webp; 26 | 27 | application/font-woff woff; 28 | application/java-archive jar war ear; 29 | application/json json; 30 | application/mac-binhex40 hqx; 31 | application/msword doc; 32 | application/pdf pdf; 33 | application/postscript ps eps ai; 34 | application/rtf rtf; 35 | application/vnd.apple.mpegurl m3u8; 36 | application/vnd.ms-excel xls; 37 | application/vnd.ms-fontobject eot; 38 | application/vnd.ms-powerpoint ppt; 39 | application/vnd.wap.wmlc wmlc; 40 | application/vnd.google-earth.kml+xml kml; 41 | application/vnd.google-earth.kmz kmz; 42 | application/x-7z-compressed 7z; 43 | application/x-cocoa cco; 44 | application/x-java-archive-diff jardiff; 45 | application/x-java-jnlp-file jnlp; 46 | application/x-makeself run; 47 | application/x-perl pl pm; 48 | application/x-pilot prc pdb; 49 | application/x-rar-compressed rar; 50 | application/x-redhat-package-manager rpm; 51 | application/x-sea sea; 52 | application/x-shockwave-flash swf; 53 | application/x-stuffit sit; 54 | application/x-tcl tcl tk; 55 | application/x-x509-ca-cert der pem crt; 56 | application/x-xpinstall xpi; 57 | application/xhtml+xml xhtml; 58 | application/xspf+xml xspf; 59 | application/zip zip; 60 | 61 | application/octet-stream bin exe dll; 62 | application/octet-stream deb; 63 | application/octet-stream dmg; 64 | application/octet-stream iso img; 65 | application/octet-stream msi msp msm; 66 | 67 | application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; 68 | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; 69 | application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; 70 | 71 | audio/midi mid midi kar; 72 | audio/mpeg mp3; 73 | audio/ogg ogg; 74 | audio/x-m4a m4a; 75 | audio/x-realaudio ra; 76 | 77 | video/3gpp 3gpp 3gp; 78 | video/mp2t ts; 79 | video/mp4 mp4; 80 | video/mpeg mpeg mpg; 81 | video/quicktime mov; 82 | video/webm webm; 83 | video/x-flv flv; 84 | video/x-m4v m4v; 85 | video/x-mng mng; 86 | video/x-ms-asf asx asf; 87 | video/x-ms-wmv wmv; 88 | video/x-msvideo avi; 89 | } 90 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/conf/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | #user nobody; 3 | worker_processes 1; 4 | 5 | #error_log logs/error.log; 6 | #error_log logs/error.log notice; 7 | #error_log logs/error.log info; 8 | 9 | #pid logs/nginx.pid; 10 | 11 | 12 | events { 13 | worker_connections 1024; 14 | } 15 | 16 | 17 | http { 18 | include mime.types; 19 | default_type application/octet-stream; 20 | 21 | #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 22 | # '$status $body_bytes_sent "$http_referer" ' 23 | # '"$http_user_agent" "$http_x_forwarded_for"'; 24 | 25 | #access_log logs/access.log main; 26 | 27 | sendfile on; 28 | #tcp_nopush on; 29 | 30 | #keepalive_timeout 0; 31 | keepalive_timeout 65; 32 | 33 | #gzip on; 34 | 35 | upstream backend { 36 | server 127.0.0.1:9000; 37 | keepalive 32; 38 | } 39 | 40 | server { 41 | listen 8082; 42 | server_name localhost; 43 | 44 | #charset koi8-r; 45 | 46 | #access_log logs/host.access.log main; 47 | 48 | location / { 49 | root html; 50 | index index.html index.htm; 51 | } 52 | 53 | #error_page 404 /404.html; 54 | 55 | # redirect server error pages to the static page /50x.html 56 | # 57 | error_page 500 502 503 504 /50x.html; 58 | location = /50x.html { 59 | root html; 60 | } 61 | 62 | # pass the ASPX pages to FastCGI server 63 | location ~ ^.+\.aspx { 64 | root html; 65 | fastcgi_keep_conn on; 66 | fastcgi_pass backend; 67 | fastcgi_index Default.aspx; 68 | 69 | fastcgi_split_path_info ^((?U).+\.aspx)(/?.+)$; 70 | fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; 71 | fastcgi_param PATH_INFO $fastcgi_path_info; 72 | fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 73 | include fastcgi_params; 74 | } 75 | 76 | location /cgi/ { 77 | root html; 78 | fastcgi_keep_conn on; 79 | fastcgi_pass backend; 80 | fastcgi_index Default.aspx; 81 | 82 | fastcgi_split_path_info ^(.*cgi)(/.*)$; 83 | fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; 84 | fastcgi_param PATH_INFO $fastcgi_path_info; 85 | fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 86 | include fastcgi_params; 87 | } 88 | 89 | # deny access to .htaccess files, if Apache's document root 90 | # concurs with nginx's one 91 | # 92 | #location ~ /\.ht { 93 | # deny all; 94 | #} 95 | } 96 | 97 | 98 | # another virtual host using mix of IP-, name-, and port-based configuration 99 | # 100 | #server { 101 | # listen 8000; 102 | # listen somename:8080; 103 | # server_name somename alias another.alias; 104 | 105 | # location / { 106 | # root html; 107 | # index index.html index.htm; 108 | # } 109 | #} 110 | 111 | 112 | # HTTPS server 113 | # 114 | #server { 115 | # listen 443 ssl; 116 | # server_name localhost; 117 | 118 | # ssl_certificate cert.pem; 119 | # ssl_certificate_key cert.key; 120 | 121 | # ssl_session_cache shared:SSL:1m; 122 | # ssl_session_timeout 5m; 123 | 124 | # ssl_ciphers HIGH:!aNULL:!MD5; 125 | # ssl_prefer_server_ciphers on; 126 | 127 | # location / { 128 | # root html; 129 | # index index.html index.htm; 130 | # } 131 | #} 132 | 133 | } 134 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/conf/scgi_params: -------------------------------------------------------------------------------- 1 | 2 | scgi_param REQUEST_METHOD $request_method; 3 | scgi_param REQUEST_URI $request_uri; 4 | scgi_param QUERY_STRING $query_string; 5 | scgi_param CONTENT_TYPE $content_type; 6 | 7 | scgi_param DOCUMENT_URI $document_uri; 8 | scgi_param DOCUMENT_ROOT $document_root; 9 | scgi_param SCGI 1; 10 | scgi_param SERVER_PROTOCOL $server_protocol; 11 | scgi_param HTTPS $https if_not_empty; 12 | 13 | scgi_param REMOTE_ADDR $remote_addr; 14 | scgi_param REMOTE_PORT $remote_port; 15 | scgi_param SERVER_PORT $server_port; 16 | scgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/conf/uwsgi_params: -------------------------------------------------------------------------------- 1 | 2 | uwsgi_param QUERY_STRING $query_string; 3 | uwsgi_param REQUEST_METHOD $request_method; 4 | uwsgi_param CONTENT_TYPE $content_type; 5 | uwsgi_param CONTENT_LENGTH $content_length; 6 | 7 | uwsgi_param REQUEST_URI $request_uri; 8 | uwsgi_param PATH_INFO $document_uri; 9 | uwsgi_param DOCUMENT_ROOT $document_root; 10 | uwsgi_param SERVER_PROTOCOL $server_protocol; 11 | uwsgi_param HTTPS $https if_not_empty; 12 | 13 | uwsgi_param REMOTE_ADDR $remote_addr; 14 | uwsgi_param REMOTE_PORT $remote_port; 15 | uwsgi_param SERVER_PORT $server_port; 16 | uwsgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/conf/win-utf: -------------------------------------------------------------------------------- 1 | 2 | # This map is not a full windows-1251 <> utf8 map: it does not 3 | # contain Serbian and Macedonian letters. If you need a full map, 4 | # use contrib/unicode2nginx/win-utf map instead. 5 | 6 | charset_map windows-1251 utf-8 { 7 | 8 | 82 E2809A ; # single low-9 quotation mark 9 | 10 | 84 E2809E ; # double low-9 quotation mark 11 | 85 E280A6 ; # ellipsis 12 | 86 E280A0 ; # dagger 13 | 87 E280A1 ; # double dagger 14 | 88 E282AC ; # euro 15 | 89 E280B0 ; # per mille 16 | 17 | 91 E28098 ; # left single quotation mark 18 | 92 E28099 ; # right single quotation mark 19 | 93 E2809C ; # left double quotation mark 20 | 94 E2809D ; # right double quotation mark 21 | 95 E280A2 ; # bullet 22 | 96 E28093 ; # en dash 23 | 97 E28094 ; # em dash 24 | 25 | 99 E284A2 ; # trade mark sign 26 | 27 | A0 C2A0 ; #   28 | A1 D18E ; # capital Byelorussian short U 29 | A2 D19E ; # small Byelorussian short u 30 | 31 | A4 C2A4 ; # currency sign 32 | A5 D290 ; # capital Ukrainian soft G 33 | A6 C2A6 ; # borken bar 34 | A7 C2A7 ; # section sign 35 | A8 D081 ; # capital YO 36 | A9 C2A9 ; # (C) 37 | AA D084 ; # capital Ukrainian YE 38 | AB C2AB ; # left-pointing double angle quotation mark 39 | AC C2AC ; # not sign 40 | AD C2AD ; # soft hypen 41 | AE C2AE ; # (R) 42 | AF D087 ; # capital Ukrainian YI 43 | 44 | B0 C2B0 ; # ° 45 | B1 C2B1 ; # plus-minus sign 46 | B2 D086 ; # capital Ukrainian I 47 | B3 D196 ; # small Ukrainian i 48 | B4 D291 ; # small Ukrainian soft g 49 | B5 C2B5 ; # micro sign 50 | B6 C2B6 ; # pilcrow sign 51 | B7 C2B7 ; # · 52 | B8 D191 ; # small yo 53 | B9 E28496 ; # numero sign 54 | BA D194 ; # small Ukrainian ye 55 | BB C2BB ; # right-pointing double angle quotation mark 56 | 57 | BF D197 ; # small Ukrainian yi 58 | 59 | C0 D090 ; # capital A 60 | C1 D091 ; # capital B 61 | C2 D092 ; # capital V 62 | C3 D093 ; # capital G 63 | C4 D094 ; # capital D 64 | C5 D095 ; # capital YE 65 | C6 D096 ; # capital ZH 66 | C7 D097 ; # capital Z 67 | C8 D098 ; # capital I 68 | C9 D099 ; # capital J 69 | CA D09A ; # capital K 70 | CB D09B ; # capital L 71 | CC D09C ; # capital M 72 | CD D09D ; # capital N 73 | CE D09E ; # capital O 74 | CF D09F ; # capital P 75 | 76 | D0 D0A0 ; # capital R 77 | D1 D0A1 ; # capital S 78 | D2 D0A2 ; # capital T 79 | D3 D0A3 ; # capital U 80 | D4 D0A4 ; # capital F 81 | D5 D0A5 ; # capital KH 82 | D6 D0A6 ; # capital TS 83 | D7 D0A7 ; # capital CH 84 | D8 D0A8 ; # capital SH 85 | D9 D0A9 ; # capital SHCH 86 | DA D0AA ; # capital hard sign 87 | DB D0AB ; # capital Y 88 | DC D0AC ; # capital soft sign 89 | DD D0AD ; # capital E 90 | DE D0AE ; # capital YU 91 | DF D0AF ; # capital YA 92 | 93 | E0 D0B0 ; # small a 94 | E1 D0B1 ; # small b 95 | E2 D0B2 ; # small v 96 | E3 D0B3 ; # small g 97 | E4 D0B4 ; # small d 98 | E5 D0B5 ; # small ye 99 | E6 D0B6 ; # small zh 100 | E7 D0B7 ; # small z 101 | E8 D0B8 ; # small i 102 | E9 D0B9 ; # small j 103 | EA D0BA ; # small k 104 | EB D0BB ; # small l 105 | EC D0BC ; # small m 106 | ED D0BD ; # small n 107 | EE D0BE ; # small o 108 | EF D0BF ; # small p 109 | 110 | F0 D180 ; # small r 111 | F1 D181 ; # small s 112 | F2 D182 ; # small t 113 | F3 D183 ; # small u 114 | F4 D184 ; # small f 115 | F5 D185 ; # small kh 116 | F6 D186 ; # small ts 117 | F7 D187 ; # small ch 118 | F8 D188 ; # small sh 119 | F9 D189 ; # small shch 120 | FA D18A ; # small hard sign 121 | FB D18B ; # small y 122 | FC D18C ; # small soft sign 123 | FD D18D ; # small e 124 | FE D18E ; # small yu 125 | FF D18F ; # small ya 126 | } 127 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/contrib/README: -------------------------------------------------------------------------------- 1 | 2 | geo2nginx.pl by Andrei Nigmatulin 3 | 4 | The perl script to convert CSV geoip database ( free download 5 | at http://www.maxmind.com/app/geoip_country ) to format, suitable 6 | for use by the ngx_http_geo_module. 7 | 8 | 9 | unicode2nginx by Maxim Dounin 10 | 11 | The perl script to convert unicode mappings ( available 12 | at http://www.unicode.org/Public/MAPPINGS/ ) to the nginx 13 | configuration file format. 14 | Two generated full maps for windows-1251 and koi8-r. 15 | 16 | 17 | vim by Evan Miller 18 | 19 | Syntax highlighting of nginx configuration for vim, to be 20 | placed into ~/.vim/. 21 | 22 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/contrib/geo2nginx.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # (c) Andrei Nigmatulin, 2005 4 | # 5 | # this script provided "as is", without any warranties. use it at your own risk. 6 | # 7 | # special thanx to Andrew Sitnikov for perl port 8 | # 9 | # this script converts CSV geoip database (free download at http://www.maxmind.com/app/geoip_country) 10 | # to format, suitable for use with nginx_http_geo module (http://sysoev.ru/nginx) 11 | # 12 | # for example, line with ip range 13 | # 14 | # "62.16.68.0","62.16.127.255","1041253376","1041268735","RU","Russian Federation" 15 | # 16 | # will be converted to four subnetworks: 17 | # 18 | # 62.16.68.0/22 RU; 19 | # 62.16.72.0/21 RU; 20 | # 62.16.80.0/20 RU; 21 | # 62.16.96.0/19 RU; 22 | 23 | 24 | use warnings; 25 | use strict; 26 | 27 | while( ){ 28 | if (/"[^"]+","[^"]+","([^"]+)","([^"]+)","([^"]+)"/){ 29 | print_subnets($1, $2, $3); 30 | } 31 | } 32 | 33 | sub print_subnets { 34 | my ($a1, $a2, $c) = @_; 35 | my $l; 36 | while ($a1 <= $a2) { 37 | for ($l = 0; ($a1 & (1 << $l)) == 0 && ($a1 + ((1 << ($l + 1)) - 1)) <= $a2; $l++){}; 38 | print long2ip($a1) . "/" . (32 - $l) . " " . $c . ";\n"; 39 | $a1 += (1 << $l); 40 | } 41 | } 42 | 43 | sub long2ip { 44 | my $ip = shift; 45 | 46 | my $str = 0; 47 | 48 | $str = ($ip & 255); 49 | 50 | $ip >>= 8; 51 | $str = ($ip & 255).".$str"; 52 | 53 | $ip >>= 8; 54 | $str = ($ip & 255).".$str"; 55 | 56 | $ip >>= 8; 57 | $str = ($ip & 255).".$str"; 58 | } 59 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/contrib/unicode2nginx/unicode-to-nginx.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # Convert unicode mappings to nginx configuration file format. 4 | 5 | # You may find useful mappings in various places, including 6 | # unicode.org official site: 7 | # 8 | # http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT 9 | # http://www.unicode.org/Public/MAPPINGS/VENDORS/MISC/KOI8-R.TXT 10 | 11 | # Needs perl 5.6 or later. 12 | 13 | # Written by Maxim Dounin, mdounin@rambler-co.ru 14 | 15 | ############################################################################### 16 | 17 | require 5.006; 18 | 19 | while (<>) { 20 | # Skip comments and empty lines 21 | 22 | next if /^#/; 23 | next if /^\s*$/; 24 | chomp; 25 | 26 | # Convert mappings 27 | 28 | if (/^\s*0x(..)\s*0x(....)\s*(#.*)/) { 29 | # Mapping "#" 30 | my $cs_code = $1; 31 | my $un_code = $2; 32 | my $un_name = $3; 33 | 34 | # Produce UTF-8 sequence from character code; 35 | 36 | my $un_utf8 = join('', map { sprintf("%02X", $_) } unpack("C*", pack("U", hex($un_code)))); 37 | 38 | print " $cs_code $un_utf8 ; $un_name\n"; 39 | 40 | } else { 41 | warn "Unrecognized line: '$_'"; 42 | } 43 | } 44 | 45 | ############################################################################### 46 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/contrib/vim/ftdetect/nginx.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.nginx set ft=nginx 2 | au BufRead,BufNewFile */etc/nginx/* set ft=nginx 3 | au BufRead,BufNewFile */usr/local/nginx/conf/* set ft=nginx 4 | au BufRead,BufNewFile nginx.conf set ft=nginx 5 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/contrib/vim/indent/nginx.vim: -------------------------------------------------------------------------------- 1 | if exists("b:did_indent") 2 | finish 3 | endif 4 | let b:did_indent = 1 5 | 6 | setlocal indentexpr= 7 | 8 | " cindent actually works for nginx' simple file structure 9 | setlocal cindent 10 | " Just make sure that the comments are not reset as defs would be. 11 | setlocal cinkeys-=0# 12 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/docs/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2014 Igor Sysoev 3 | * Copyright (C) 2011-2014 Nginx, Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/docs/PCRE.LICENCE: -------------------------------------------------------------------------------- 1 | PCRE LICENCE 2 | ------------ 3 | 4 | PCRE is a library of functions to support regular expressions whose syntax 5 | and semantics are as close as possible to those of the Perl 5 language. 6 | 7 | Release 8 of PCRE is distributed under the terms of the "BSD" licence, as 8 | specified below. The documentation for PCRE, supplied in the "doc" 9 | directory, is distributed under the same terms as the software itself. 10 | 11 | The basic library functions are written in C and are freestanding. Also 12 | included in the distribution is a set of C++ wrapper functions, and a 13 | just-in-time compiler that can be used to optimize pattern matching. These 14 | are both optional features that can be omitted when the library is built. 15 | 16 | 17 | THE BASIC LIBRARY FUNCTIONS 18 | --------------------------- 19 | 20 | Written by: Philip Hazel 21 | Email local part: ph10 22 | Email domain: cam.ac.uk 23 | 24 | University of Cambridge Computing Service, 25 | Cambridge, England. 26 | 27 | Copyright (c) 1997-2014 University of Cambridge 28 | All rights reserved. 29 | 30 | 31 | PCRE JUST-IN-TIME COMPILATION SUPPORT 32 | ------------------------------------- 33 | 34 | Written by: Zoltan Herczeg 35 | Email local part: hzmester 36 | Emain domain: freemail.hu 37 | 38 | Copyright(c) 2010-2014 Zoltan Herczeg 39 | All rights reserved. 40 | 41 | 42 | STACK-LESS JUST-IN-TIME COMPILER 43 | -------------------------------- 44 | 45 | Written by: Zoltan Herczeg 46 | Email local part: hzmester 47 | Emain domain: freemail.hu 48 | 49 | Copyright(c) 2009-2014 Zoltan Herczeg 50 | All rights reserved. 51 | 52 | 53 | THE C++ WRAPPER FUNCTIONS 54 | ------------------------- 55 | 56 | Contributed by: Google Inc. 57 | 58 | Copyright (c) 2007-2012, Google Inc. 59 | All rights reserved. 60 | 61 | 62 | THE "BSD" LICENCE 63 | ----------------- 64 | 65 | Redistribution and use in source and binary forms, with or without 66 | modification, are permitted provided that the following conditions are met: 67 | 68 | * Redistributions of source code must retain the above copyright notice, 69 | this list of conditions and the following disclaimer. 70 | 71 | * Redistributions in binary form must reproduce the above copyright 72 | notice, this list of conditions and the following disclaimer in the 73 | documentation and/or other materials provided with the distribution. 74 | 75 | * Neither the name of the University of Cambridge nor the name of Google 76 | Inc. nor the names of their contributors may be used to endorse or 77 | promote products derived from this software without specific prior 78 | written permission. 79 | 80 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 81 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 82 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 83 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 84 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 85 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 86 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 87 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 88 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 89 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 90 | POSSIBILITY OF SUCH DAMAGE. 91 | 92 | End 93 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/docs/README: -------------------------------------------------------------------------------- 1 | 2 | Documentation is available at http://nginx.org 3 | 4 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/docs/zlib.LICENSE: -------------------------------------------------------------------------------- 1 | (C) 1995-2013 Jean-loup Gailly and Mark Adler 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | 19 | Jean-loup Gailly Mark Adler 20 | jloup@gzip.org madler@alumni.caltech.edu 21 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/html/50x.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Error 5 | 12 | 13 | 14 |

An error occurred.

15 |

Sorry, the page you are looking for is currently unavailable.
16 | Please try again later.

17 |

If you are the system administrator of this resource then you should check 18 | the error log for details.

19 |

Faithfully yours, nginx.

20 | 21 | 22 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to nginx! 5 | 12 | 13 | 14 |

Welcome to nginx!

15 |

If you see this page, the nginx web server is successfully installed and 16 | working. Further configuration is required.

17 | 18 |

For online documentation and support please refer to 19 | nginx.org.
20 | Commercial support is available at 21 | nginx.com.

22 | 23 |

Thank you for using nginx.

24 | 25 | 26 | -------------------------------------------------------------------------------- /Examples/windows-nginx-1.6.2/nginx.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gigi81/sharpfastcgi/e5aeead9f9be13e423067de2de876ba9821f81b2/Examples/windows-nginx-1.6.2/nginx.exe -------------------------------------------------------------------------------- /FastCgi.AspNet/AspNetChannel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Grillisoft.FastCgi.Protocol; 6 | 7 | namespace Grillisoft.FastCgi.AspNet 8 | { 9 | public class AspNetChannel : FastCgiChannel 10 | { 11 | private readonly IAspNetRequestConfig _config; 12 | 13 | public AspNetChannel(ILowerLayer lowerLayer, ILoggerFactory loggerFactory, IAspNetRequestConfig config) 14 | : base(lowerLayer, new Repositories.SyncronizedRequestsRepository(), loggerFactory) 15 | { 16 | _config = config; 17 | } 18 | 19 | protected override Request CreateRequest(ushort requestId, BeginRequestMessageBody body) 20 | { 21 | return new AspNetRequest(requestId, body, _config); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /FastCgi.AspNet/AspNetChannelFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Grillisoft.FastCgi; 3 | using Grillisoft.FastCgi.Protocol; 4 | using Grillisoft.FastCgi.AspNet; 5 | 6 | namespace Grillisoft.FastCgi.AspNet 7 | { 8 | public class AspNetChannelFactory : IFastCgiChannelFactory 9 | { 10 | ILoggerFactory _loggerFactory; 11 | IAspNetRequestConfig _requestConfig; 12 | 13 | public AspNetChannelFactory (ILoggerFactory loggerFactory, IAspNetRequestConfig requestConfig) 14 | { 15 | _loggerFactory = loggerFactory; 16 | _requestConfig = requestConfig; 17 | } 18 | 19 | /// 20 | /// Creates a new FastCgiChannel 21 | /// 22 | /// Lower used to communicate with the web server 23 | public FastCgiChannel CreateChannel(ILowerLayer tcpLayer) 24 | { 25 | return new AspNetChannel(tcpLayer, _loggerFactory, _requestConfig); 26 | } 27 | } 28 | 29 | public class AspNetRequestConfig : IAspNetRequestConfig 30 | { 31 | public string VirtualPath { get; set; } 32 | 33 | public string PhysicalPath { get; set ; } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /FastCgi.AspNet/AspNetHosting.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Web; 27 | using System.Web.Hosting; 28 | using System.IO; 29 | using System.Runtime.Remoting; 30 | using System.Globalization; 31 | 32 | namespace FastCgi.AspNet 33 | { 34 | public class MyAspHost 35 | { 36 | public static object CreateApplicationHost(Type hostType, string virtualDir, string physicalDir) 37 | { 38 | if (!(physicalDir.EndsWith("\\"))) 39 | physicalDir = physicalDir + "\\"; 40 | 41 | string aspDir = HttpRuntime.AspInstallDirectory; 42 | string domainId = DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo).GetHashCode().ToString("x"); 43 | string appName = (virtualDir + physicalDir).GetHashCode().ToString("x"); 44 | 45 | AppDomainSetup setup = new AppDomainSetup(); 46 | setup.ApplicationName = appName; 47 | setup.ConfigurationFile = "web.config"; // not necessary execept for debugging 48 | AppDomain ad = AppDomain.CreateDomain(domainId, null, setup); 49 | ad.SetData(".appDomain", "*"); 50 | ad.SetData(".appPath", physicalDir); 51 | ad.SetData(".appVPath", virtualDir); 52 | ad.SetData(".domainId", domainId); 53 | ad.SetData(".hostingVirtualPath", virtualDir); 54 | ad.SetData(".hostingInstallDir", aspDir); 55 | ObjectHandle oh = ad.CreateInstance(hostType.Module.Assembly.FullName, hostType.FullName); 56 | return oh.Unwrap(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /FastCgi.AspNet/AspNetRequest.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Collections.Specialized; 28 | using System.Text; 29 | using System.Threading; 30 | using Grillisoft.FastCgi.Protocol; 31 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 32 | using System.Threading.Tasks; 33 | using System.Web.Hosting; 34 | 35 | namespace Grillisoft.FastCgi.AspNet 36 | { 37 | public class AspNetRequest : Request 38 | { 39 | private IAspNetRequestConfig _config; 40 | 41 | public AspNetRequest(ushort id, BeginRequestMessageBody body, IAspNetRequestConfig config) 42 | : base(id, body) 43 | { 44 | _config = config; 45 | this.Status = String.Empty; 46 | this.Headers = new NameValueCollection(); 47 | } 48 | 49 | public string VirtualPath { get { return _config.VirtualPath; } } 50 | 51 | public string PhysicalPath { get { return _config.PhysicalPath; } } 52 | 53 | public bool HeaderSent { get; protected set; } 54 | 55 | public string Status { get; protected set; } 56 | 57 | public NameValueCollection Headers { get; protected set; } 58 | 59 | public void SetStatus(int statusCode, string statusDescription) 60 | { 61 | if (this.HeaderSent) 62 | throw new InvalidOperationException("Cannot set status on a response that has already been flushed"); 63 | 64 | this.Status = String.Format("Status: {0} {1}", statusCode, statusDescription); 65 | } 66 | 67 | public void SetHeader(string name, string value) 68 | { 69 | if (this.HeaderSent) 70 | throw new InvalidOperationException("Cannot set headers on a response that has already been flushed"); 71 | 72 | this.Headers.Set(name, value); 73 | } 74 | 75 | protected override void OnOutputStreamFlushing(FlushEventArgs args) 76 | { 77 | if (!this.HeaderSent) 78 | { 79 | args = new FlushEventArgs(this.SerializeHeaders() + args.Data); 80 | this.HeaderSent = true; 81 | } 82 | 83 | base.OnOutputStreamFlushing(args); 84 | } 85 | 86 | public override void Execute() 87 | { 88 | System.Web.HttpRuntime.ProcessRequest(new FastCgiWorkerRequest(this)); 89 | } 90 | 91 | /// 92 | /// This is single threaded so we can't abort the request 93 | /// 94 | public override void Abort() 95 | { 96 | throw new InvalidOperationException("Abort is not available"); 97 | } 98 | 99 | protected virtual ByteArray SerializeHeaders() 100 | { 101 | var builder = new StringBuilder(); 102 | 103 | if (!String.IsNullOrEmpty(this.Status)) 104 | { 105 | builder.Append(this.Status); 106 | builder.Append("\r\n"); 107 | } 108 | 109 | foreach (string key in this.Headers.Keys) 110 | { 111 | builder.Append(key); 112 | builder.Append(": "); 113 | builder.Append(this.Headers[key]); 114 | builder.Append("\r\n"); 115 | } 116 | 117 | builder.Append("\r\n"); 118 | 119 | //TODO: can improve performance without creating the temporary array 120 | return new ByteArray(Encoding.UTF8.GetBytes(builder.ToString())); 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /FastCgi.AspNet/FastCgi.AspNet.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {315E3781-3E29-459B-A0D6-EF880F60D6E0} 7 | Library 8 | Properties 9 | Grillisoft.FastCgi.AspNet 10 | Grillisoft.FastCgi.AspNet 11 | v4.0 12 | 512 13 | false 14 | FastCgi.AspNet.key 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | true 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | {A3C516B6-046B-44C2-9387-2D01646589C9} 52 | FastCgi 53 | 54 | 55 | {AFE9FDDE-332C-41A5-8DA5-6C974F9E6956} 56 | ImmutableArray 57 | 58 | 59 | 60 | 61 | 62 | 63 | 70 | -------------------------------------------------------------------------------- /FastCgi.AspNet/FastCgi.AspNet.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gigi81/sharpfastcgi/e5aeead9f9be13e423067de2de876ba9821f81b2/FastCgi.AspNet/FastCgi.AspNet.key -------------------------------------------------------------------------------- /FastCgi.AspNet/FastCgi.AspNet.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | Luigi Grilli 7 | Luigi Grilli 8 | https://github.com/gigi81/sharpfastcgi/blob/master/LICENSE.txt 9 | https://github.com/gigi81/sharpfastcgi 10 | false 11 | FastCgi Aspnet integration library 12 | Initial nuget release 13 | Copyright 2018 Luigi Grilli 14 | fastcgi web server 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /FastCgi.AspNet/FastCgiAspNetServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Net; 5 | using System.Runtime.Remoting; 6 | using System.Threading; 7 | using System.Web.Hosting; 8 | using Grillisoft.FastCgi.Protocol; 9 | using Grillisoft.FastCgi.Servers; 10 | 11 | namespace Grillisoft.FastCgi.AspNet 12 | { 13 | public class FastCgiAspNetServer : MarshalByRefObject 14 | { 15 | private IFastCgiServer _server; 16 | 17 | /// 18 | /// Create a fastcgi server 19 | /// 20 | /// Tcp/ip port where the server will be listening for fastcgi requests 21 | /// Virtual path of your ASP.NET application 22 | /// Physical path of your ASP.NET application 23 | /// 24 | public static FastCgiAspNetServer CreateApplicationHost(IPAddress address, int port, string virtualPath, string physicalPath, ILoggerFactory loggerFactory) 25 | { 26 | var ret = (FastCgiAspNetServer)ApplicationHost.CreateApplicationHost(typeof(FastCgiAspNetServer), virtualPath, physicalPath); 27 | ret.CreateServer (address, port, virtualPath, physicalPath, loggerFactory); 28 | return ret; 29 | } 30 | 31 | private void CreateServer(IPAddress address, int port, string virtualPath, string physicalPath, ILoggerFactory loggerFactory) 32 | { 33 | var channelFactory = new AspNetChannelFactory (loggerFactory, new AspNetRequestConfig { 34 | VirtualPath = virtualPath, 35 | PhysicalPath = physicalPath 36 | }); 37 | 38 | _server = new TcpServer(address, port, channelFactory); 39 | } 40 | 41 | public override object InitializeLifetimeService() 42 | { 43 | return null; //never expire lease 44 | } 45 | 46 | /// 47 | /// Start listening for incoming connections 48 | /// 49 | public void Start() 50 | { 51 | _server.Start(); 52 | } 53 | 54 | /// 55 | /// Stop listening for incoming connections 56 | /// 57 | public void Stop() 58 | { 59 | _server.Stop(); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /FastCgi.AspNet/IAspNetRequestConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Grillisoft.FastCgi.AspNet 7 | { 8 | public interface IAspNetRequestConfig 9 | { 10 | string VirtualPath { get; } 11 | 12 | string PhysicalPath { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /FastCgi.AspNet/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FastCgi.AspNet")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FastCgi.AspNet")] 13 | [assembly: AssemblyCopyright("Copyright © Luigi Grilli 2012 - 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("63cb8c6d-e5af-4aab-b74d-76068aa6af32")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FastCgi.Loggers.Log4Net/FastCgi.Loggers.Log4Net.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {EE31060B-980B-4E24-AE84-0DF6A0F0E95D} 8 | Library 9 | Properties 10 | Grillisoft.FastCgi.Loggers.Log4Net 11 | Grillisoft.FastCgi.Loggers.Log4Net 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | ..\packages\log4net.2.0.8\lib\net40-full\log4net.dll 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | {a3c516b6-046b-44c2-9387-2d01646589c9} 57 | FastCgi 58 | 59 | 60 | 61 | 68 | -------------------------------------------------------------------------------- /FastCgi.Loggers.Log4Net/FastCgi.Loggers.Log4Net.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | Luigi Grilli 7 | Luigi Grilli 8 | https://github.com/gigi81/sharpfastcgi/blob/master/LICENSE.txt 9 | https://github.com/gigi81/sharpfastcgi 10 | false 11 | FastCgi logging log4net integration library 12 | Initial nuget release 13 | Copyright 2018 Luigi Grilli 14 | fastcgi web server 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /FastCgi.Loggers.Log4Net/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Grillisoft.FastCgi.Loggers.Log4Net 8 | { 9 | internal class Logger : Grillisoft.FastCgi.ILogger 10 | { 11 | private readonly log4net.ILog _logger; 12 | 13 | public Logger(log4net.ILog logger) 14 | { 15 | _logger = logger; 16 | } 17 | 18 | public void Log(Grillisoft.FastCgi.LogLevel level, string format, params object[] args) 19 | { 20 | switch (level) 21 | { 22 | case Grillisoft.FastCgi.LogLevel.Critical: 23 | _logger.FatalFormat(format, args); 24 | break; 25 | case Grillisoft.FastCgi.LogLevel.Error: 26 | _logger.ErrorFormat(format, args); 27 | break; 28 | case Grillisoft.FastCgi.LogLevel.Warning: 29 | _logger.WarnFormat(format, args); 30 | break; 31 | case Grillisoft.FastCgi.LogLevel.Info: 32 | _logger.InfoFormat(format, args); 33 | break; 34 | case Grillisoft.FastCgi.LogLevel.Verbose: 35 | _logger.DebugFormat(format, args); 36 | break; 37 | default: 38 | break; 39 | } 40 | } 41 | 42 | public void Log(Grillisoft.FastCgi.LogLevel level, Exception ex, string format, params object[] args) 43 | { 44 | try 45 | { 46 | format = format ?? String.Empty; 47 | args = args ?? new object[0]; 48 | 49 | switch (level) 50 | { 51 | case Grillisoft.FastCgi.LogLevel.Critical: 52 | _logger.Fatal(String.Format(format, args), ex); 53 | break; 54 | case Grillisoft.FastCgi.LogLevel.Error: 55 | _logger.Error(String.Format(format, args), ex); 56 | break; 57 | case Grillisoft.FastCgi.LogLevel.Warning: 58 | _logger.Warn(String.Format(format, args), ex); 59 | break; 60 | case Grillisoft.FastCgi.LogLevel.Info: 61 | _logger.Info(String.Format(format, args), ex); 62 | break; 63 | case Grillisoft.FastCgi.LogLevel.Verbose: 64 | _logger.Debug(String.Format(format, args), ex); 65 | break; 66 | default: 67 | break; 68 | } 69 | } 70 | catch(FormatException formatException) 71 | { 72 | _logger.Error("Invalid log format", formatException); 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /FastCgi.Loggers.Log4Net/Loggerfactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Grillisoft.FastCgi.Loggers.Log4Net 4 | { 5 | [Serializable] 6 | public sealed class LoggerFactory : ILoggerFactory 7 | { 8 | public ILogger Create(Type type) 9 | { 10 | return new Logger(log4net.LogManager.GetLogger(type)); 11 | } 12 | 13 | public ILogger Create(string name) 14 | { 15 | return new Logger(log4net.LogManager.GetLogger(name)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FastCgi.Loggers.Log4Net/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FastCgi.Loggers.Log4Net")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FastCgi.Loggers.Log4Net")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("728b288c-ae94-4f5f-a7d4-07cddbd92715")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | 38 | [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.xml", Watch = true)] -------------------------------------------------------------------------------- /FastCgi.Loggers.Log4Net/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /FastCgi.Owin/Constants.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace Grillisoft.FastCgi.Owin 5 | { 6 | internal static class Constants 7 | { 8 | public static readonly KeyValuePair OwinVersion = new KeyValuePair("owin.Version", "1.0"); 9 | 10 | // Owin Spec states host SHOULD send a reason phrase according to RFC 2616 section 6.1.1 when not supplied by the application 11 | public static readonly IReadOnlyDictionary ReasonPhrases = new ReadOnlyDictionary(new Dictionary(){ 12 | { 100, "Continue" }, 13 | { 101, "Switching Protocols" }, 14 | { 200, "OK" }, 15 | { 201, "Created" }, 16 | { 202, "Accepted" }, 17 | { 203, "Non-Authoritative Information" }, 18 | { 204, "No Content" }, 19 | { 205, "Reset Content" }, 20 | { 206, "Partial Content" }, 21 | { 300, "Multiple Choices" }, 22 | { 301, "Moved Permanently" }, 23 | { 302, "Found" }, 24 | { 303, "See Other" }, 25 | { 304, "Not Modified" }, 26 | { 305, "Use Proxy" }, 27 | { 307, "Temporary Redirect" }, 28 | { 400, "Bad Request" }, 29 | { 401, "Unauthorized" }, 30 | { 402, "Payment Required" }, 31 | { 403, "Forbidden" }, 32 | { 404, "Not Found" }, 33 | { 405, "Method Not Allowed" }, 34 | { 406, "Not Acceptable" }, 35 | { 407, "Proxy Authentication Required" }, 36 | { 408, "Request Time-out" }, 37 | { 409, "Conflict" }, 38 | { 410, "Gone" }, 39 | { 411, "Length Required" }, 40 | { 412, "Precondition Failed" }, 41 | { 413, "Request Entity Too Large" }, 42 | { 414, "Request-URI Too Large" }, 43 | { 415, "Unsupported Media Type" }, 44 | { 416, "Requested range not satisfiable" }, 45 | { 417, "Expectation Failed" }, 46 | { 500, "Internal Server Error" }, 47 | { 501, "Not Implemented" }, 48 | { 502, "Bad Gateway" }, 49 | { 503, "Service Unavailable" }, 50 | { 504, "Gateway Time-out" }, 51 | { 505, "HTTP Version not supported" } 52 | }); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /FastCgi.Owin/FastCgi.Owin.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {22F4FD2E-F0D6-4EAF-84FC-D3F048C4A3E6} 8 | Library 9 | Properties 10 | Grillisoft.FastCgi.Owin 11 | Grillisoft.FastCgi.Owin 12 | v4.5.1 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | 37 | ..\packages\Microsoft.Owin.4.0.0\lib\net451\Microsoft.Owin.dll 38 | 39 | 40 | ..\packages\Owin.1.0\lib\net40\Owin.dll 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | {a3c516b6-046b-44c2-9387-2d01646589c9} 60 | FastCgi 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /FastCgi.Owin/FastCgi.Owin.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | Luigi Grilli 7 | Luigi Grilli 8 | https://github.com/gigi81/sharpfastcgi/blob/master/LICENSE.txt 9 | https://github.com/gigi81/sharpfastcgi 10 | false 11 | FastCgi Owin integration library 12 | Initial nuget release 13 | Copyright 2018 Luigi Grilli and Mike Davis 14 | fastcgi owin web server 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /FastCgi.Owin/OwinChannel.cs: -------------------------------------------------------------------------------- 1 | using Grillisoft.FastCgi.Protocol; 2 | 3 | namespace Grillisoft.FastCgi.Owin 4 | { 5 | public class OwinChannel : SimpleFastCgiChannel 6 | { 7 | Microsoft.Owin.OwinMiddleware pipeline; 8 | 9 | public OwinChannel(ILowerLayer layer, ILoggerFactory loggerFactory, Microsoft.Owin.OwinMiddleware pipeline) 10 | : base(layer, loggerFactory) 11 | { 12 | this.pipeline = pipeline; 13 | } 14 | 15 | protected override Request CreateRequest(ushort requestId, BeginRequestMessageBody body) 16 | { 17 | return new OwinRequest(requestId, body, pipeline); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /FastCgi.Owin/OwinChannelFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Grillisoft.FastCgi; 3 | using Grillisoft.FastCgi.Protocol; 4 | using Microsoft.Owin; 5 | using Microsoft.Owin.Builder; 6 | using Owin; 7 | 8 | namespace Grillisoft.FastCgi.Owin 9 | { 10 | public class OwinChannelFactory : IFastCgiChannelFactory 11 | { 12 | private readonly ILoggerFactory loggerFactory; 13 | private readonly Action appInitializer; 14 | 15 | public OwinChannelFactory(ILoggerFactory loggerFactory, Action appInitializer) 16 | { 17 | this.loggerFactory = loggerFactory; 18 | this.appInitializer = appInitializer; 19 | } 20 | 21 | public FastCgiChannel CreateChannel(ILowerLayer lowerLayer) 22 | { 23 | IAppBuilder appBuilder = new AppBuilder(); 24 | appBuilder.Properties.Add(Constants.OwinVersion); 25 | appInitializer(appBuilder); 26 | 27 | OwinMiddleware pipeline = appBuilder.Build(); 28 | return new OwinChannel(lowerLayer, loggerFactory, pipeline); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /FastCgi.Owin/OwinRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | using System.Threading; 6 | using Grillisoft.FastCgi.Protocol; 7 | using Microsoft.Owin; 8 | 9 | namespace Grillisoft.FastCgi.Owin 10 | { 11 | public class OwinRequest : Request 12 | { 13 | private readonly OwinMiddleware pipeline; 14 | private readonly OwinContext context = new OwinContext(); 15 | private List, object>> onSendHeadersCallbacks = new List, object>>(); 16 | private readonly MemoryStream responseBody = new MemoryStream(); 17 | private readonly CancellationTokenSource cts = new CancellationTokenSource(); 18 | 19 | public OwinRequest(ushort id, BeginRequestMessageBody body, OwinMiddleware pipeline) : base(id, body) 20 | { 21 | this.pipeline = pipeline; 22 | context.Set, object>>("server.OnSendingHeaders", RegisterOnSendingHeadersCallback); 23 | } 24 | 25 | public override void Abort() 26 | { 27 | cts.Cancel(); 28 | } 29 | 30 | public override void Execute() 31 | { 32 | try 33 | { 34 | SetOwinContextValues(); 35 | 36 | using (var task = pipeline.Invoke(context)) 37 | { 38 | task.Wait(); 39 | } 40 | 41 | SendHeaders(); 42 | responseBody.Position = 0; 43 | responseBody.CopyTo(this.OutputStream); 44 | } 45 | // TODO: Catch exceptions and log 46 | finally 47 | { 48 | this.End(); 49 | this.responseBody.Dispose(); 50 | this.cts.Dispose(); 51 | } 52 | } 53 | 54 | private void SetOwinContextValues() 55 | { 56 | context.Environment.Add(Constants.OwinVersion); 57 | context.Request.CallCancelled = cts.Token; 58 | context.Request.Body = this.InputStream.Length == 0 ? Stream.Null : this.InputStream; 59 | context.Response.Body = responseBody; 60 | var headers = context.Request.Headers; 61 | 62 | foreach (var nvp in this.Parameters) 63 | { 64 | string uName = nvp.Name.ToUpperInvariant(); 65 | switch (uName) 66 | { 67 | case "SERVER_PROTOCOL": 68 | context.Request.Protocol = nvp.Value; 69 | continue; 70 | case "REQUEST_METHOD": 71 | context.Request.Method = nvp.Value.ToUpperInvariant(); 72 | continue; 73 | case "QUERY_STRING": 74 | context.Request.QueryString = new QueryString(nvp.Value); 75 | continue; 76 | case "HTTPS": 77 | context.Request.Scheme = nvp.Value.Equals("on", StringComparison.OrdinalIgnoreCase) ? "https" : "http"; 78 | continue; 79 | case "PATH_INFO": 80 | context.Request.PathBase = new PathString(string.Empty); 81 | context.Request.Path = new PathString(nvp.Value); 82 | continue; 83 | } 84 | 85 | if (uName.StartsWith("HTTP_")) 86 | { 87 | headers.Add(uName.Substring(5).Replace('_', '-'), new string[] { nvp.Value } ); 88 | } 89 | } 90 | 91 | context.Response.Protocol = context.Request.Protocol; 92 | } 93 | 94 | private void SendHeaders() 95 | { 96 | foreach (var callbackTuple in onSendHeadersCallbacks) 97 | { 98 | callbackTuple.Item1(callbackTuple.Item2); 99 | } 100 | 101 | using (var writer = new StreamWriter(this.OutputStream, Encoding.ASCII, 1024, true)) 102 | { 103 | writer.WriteLine($"Status: {context.Response.StatusCode} {context.Response.ReasonPhrase ?? Constants.ReasonPhrases[context.Response.StatusCode]}"); 104 | 105 | foreach (var header in context.Response.Headers) 106 | { 107 | writer.WriteLine($"{header.Key}: {string.Join(", ", header.Value)}"); 108 | } 109 | 110 | if (!context.Response.ContentLength.HasValue) 111 | { 112 | writer.WriteLine($"Content-Length: {responseBody.Length}"); 113 | } 114 | 115 | writer.WriteLine(); 116 | } 117 | } 118 | 119 | private void RegisterOnSendingHeadersCallback(Action callback, object state) 120 | { 121 | onSendHeadersCallbacks.Add(Tuple.Create(callback, state)); 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /FastCgi.Owin/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FastCgi.Owin")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FastCgi.Owin")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("22f4fd2e-f0d6-4eaf-84fc-d3f048c4a3e6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FastCgi.Owin/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /FastCgi.Server/AspNetRequestConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Grillisoft.FastCgi.AspNet; 3 | 4 | namespace Grillisoft.FastCgi.Server 5 | { 6 | public class AspNetRequestConfig : IAspNetRequestConfig 7 | { 8 | public string VirtualPath 9 | { 10 | get { return Config.VirtualPath; } 11 | } 12 | 13 | public string PhysicalPath 14 | { 15 | get { return Config.PhysicalPath; } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FastCgi.Server/Config.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Net; 4 | using System.Configuration; 5 | 6 | namespace Grillisoft.FastCgi.Server 7 | { 8 | internal class Config 9 | { 10 | private const string DefaultVirtualPath = "/"; 11 | private const string DefaultPhysicalPath = "Root"; 12 | private static IPAddress DefaultAddress = IPAddress.Any; 13 | private const int DefaultPort = 9000; 14 | 15 | public static string VirtualPath 16 | { 17 | get { return ConfigurationManager.AppSettings["VirtualPath"] ?? DefaultVirtualPath; } 18 | } 19 | 20 | public static string PhysicalPath 21 | { 22 | get 23 | { 24 | return Path.GetFullPath(ConfigurationManager.AppSettings["PhysicalPath"] ?? DefaultPhysicalPath); 25 | } 26 | } 27 | 28 | public static IPAddress Address 29 | { 30 | get 31 | { 32 | var value = ConfigurationManager.AppSettings ["Address"]; 33 | 34 | IPAddress ret; 35 | if (!String.IsNullOrWhiteSpace(value) && IPAddress.TryParse(ConfigurationManager.AppSettings["Address"], out ret)) 36 | return ret; 37 | 38 | return DefaultAddress; 39 | } 40 | } 41 | 42 | public static int Port 43 | { 44 | get 45 | { 46 | int ret; 47 | if (Int32.TryParse(ConfigurationManager.AppSettings["Port"], out ret)) 48 | return ret; 49 | 50 | return DefaultPort; 51 | } 52 | } 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /FastCgi.Server/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Web.Hosting; 7 | using Grillisoft.FastCgi.AspNet; 8 | using System.Configuration; 9 | using Grillisoft.FastCgi.Servers; 10 | using Topshelf; 11 | using log4net; 12 | 13 | namespace Grillisoft.FastCgi.Server 14 | { 15 | class Program 16 | { 17 | private static readonly ILog Logger = log4net.LogManager.GetLogger(typeof(Program)); 18 | 19 | static void Main(string[] args) 20 | { 21 | Logger.Info("Starting FastCgi Server"); 22 | 23 | HostFactory.Run(x => 24 | { 25 | x.Service(s => 26 | { 27 | s.ConstructUsing(name => CreateServer()); 28 | s.WhenStarted(tc => { 29 | tc.Start(); 30 | Logger.InfoFormat("Listening on {0}:{1}", Config.Address, Config.Port); 31 | }); 32 | s.WhenStopped(tc => tc.Stop()); 33 | }); 34 | 35 | x.SetDescription("Asp.NET FastCgi Service"); 36 | x.SetDisplayName("Asp.NET FastCgi Service"); 37 | x.SetServiceName("aspnet-fastcgi"); 38 | x.UseLinuxIfAvailable(); 39 | x.UseLog4Net(); 40 | }); 41 | } 42 | 43 | static FastCgiAspNetServer CreateServer() 44 | { 45 | var loggerFactory = new Loggers.Log4Net.LoggerFactory(); 46 | return FastCgiAspNetServer.CreateApplicationHost(Config.Address, Config.Port, Config.VirtualPath, Config.PhysicalPath, loggerFactory); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /FastCgi.Server/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FastCgi.Server")] 9 | [assembly: AssemblyDescription("FastCgi ASP.NET Server")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FastCgi.Server")] 13 | [assembly: AssemblyCopyright("Copyright © Luigi Grilli 2011 - 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2f3dd7f0-7ef8-47b7-afc6-64ec73c3ea9a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | 38 | [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)] -------------------------------------------------------------------------------- /FastCgi.Server/Root/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /FastCgi.Server/Root/test.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" EnableSessionState="true" ContentType="text/html" ResponseEncoding="utf-8" %> 2 | Hello world!
3 | Datetime here is: <% = DateTime.Now.ToString() %>
4 | Last Request from you was: 5 | <% 6 | Response.Write(Session["LastRequest"] != null ? DateTime.Now.ToString() : "n/a"); 7 | %>
8 | 9 | Path is: <% =Request.Path %>
10 | PathInfo is: <% =Request.PathInfo %>
11 | Session ID: <% =Session.SessionID %>
12 | 13 | <% 14 | Session["LastRequest"] = DateTime.Now; 15 | %> 16 | -------------------------------------------------------------------------------- /FastCgi.Server/Root/trace.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Trace="true" EnableSessionState="true" Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %> -------------------------------------------------------------------------------- /FastCgi.Server/TcpServerConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Net; 6 | using Grillisoft.FastCgi.Servers; 7 | using System.Configuration; 8 | 9 | namespace Grillisoft.FastCgi.Server 10 | { 11 | public class TcpServerConfig : ITcpServerConfig 12 | { 13 | public IPAddress Address 14 | { 15 | get { return Config.Address; } 16 | } 17 | 18 | public int Port 19 | { 20 | get { return Config.Port; } 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /FastCgi.Server/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /FastCgi.Server/log4net.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /FastCgi.Server/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /FastCgi.Test/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using Grillisoft.FastCgi.Servers; 4 | using log4net; 5 | 6 | namespace Grillisoft.FastCgi.Test 7 | { 8 | class Program 9 | { 10 | static int Main(string[] args) 11 | { 12 | var logger = LoggerFactory.Create("Test"); 13 | logger.Log(LogLevel.Info, "Starting fastcgi server"); 14 | 15 | var server = CreateServer(); 16 | server.Start(); 17 | 18 | while(true) 19 | { 20 | Thread.Sleep(1000); 21 | } 22 | 23 | return 0; 24 | } 25 | 26 | private static IFastCgiServer CreateServer() 27 | { 28 | return new IisServer(new SimpleChannelFactory(LoggerFactory), LoggerFactory); 29 | } 30 | 31 | private static ILoggerFactory _loggerFactory; 32 | 33 | private static ILoggerFactory LoggerFactory 34 | { 35 | get 36 | { 37 | if (_loggerFactory != null) 38 | return _loggerFactory; 39 | 40 | return _loggerFactory = new Grillisoft.FastCgi.Loggers.Log4Net.LoggerFactory(); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /FastCgi.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FastCgi.Test")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FastCgi.Test")] 13 | [assembly: AssemblyCopyright("Copyright © Luigi Grilli 2012 - 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1b470132-816a-4d1c-a6d5-c71bbad8eb2e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | 38 | [assembly: log4net.Config.XmlConfigurator(ConfigFile="log4net.xml", Watch = true)] -------------------------------------------------------------------------------- /FastCgi.Test/SimpleChannel.cs: -------------------------------------------------------------------------------- 1 | using Grillisoft.FastCgi.Protocol; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Grillisoft.FastCgi.Test 8 | { 9 | public class SimpleChannel : Grillisoft.FastCgi.Protocol.SimpleFastCgiChannel 10 | { 11 | public SimpleChannel(ILowerLayer layer, ILoggerFactory loggerFactory) 12 | : base(layer, loggerFactory) 13 | { 14 | } 15 | 16 | protected override Protocol.Request CreateRequest(ushort requestId, Protocol.BeginRequestMessageBody body) 17 | { 18 | return new SimpleRequest(requestId, body); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /FastCgi.Test/SimpleChannelFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Grillisoft.FastCgi.Test 7 | { 8 | internal class SimpleChannelFactory : IFastCgiChannelFactory 9 | { 10 | private readonly ILoggerFactory _loggerFactory; 11 | 12 | public SimpleChannelFactory(ILoggerFactory loggerFactory) 13 | { 14 | _loggerFactory = loggerFactory; 15 | } 16 | 17 | public Protocol.FastCgiChannel CreateChannel(Protocol.ILowerLayer layer) 18 | { 19 | return new SimpleChannel(layer, _loggerFactory); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /FastCgi.Test/SimpleRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using System.Diagnostics; 7 | using Grillisoft.FastCgi.Protocol; 8 | using System.Threading; 9 | 10 | namespace Grillisoft.FastCgi.Test 11 | { 12 | public class SimpleRequest : Request 13 | { 14 | public static int _requests = 0; 15 | 16 | public SimpleRequest(ushort id, BeginRequestMessageBody body) 17 | : base(id, body) 18 | { 19 | } 20 | 21 | public override void Execute() 22 | { 23 | try 24 | { 25 | var body = Encoding.UTF8.GetBytes(this.GetResponseContent()); 26 | var header = Encoding.UTF8.GetBytes(this.GetResponseHeaders(body.Length)); 27 | 28 | this.OutputStream.Write(header, 0, header.Length); 29 | this.OutputStream.Write(body, 0, body.Length); 30 | } 31 | catch (Exception ex) 32 | { 33 | Debug.WriteLine(ex.Message); 34 | this.ExitCode = -1; 35 | } 36 | finally 37 | { 38 | this.End(); 39 | } 40 | } 41 | 42 | private string GetResponseHeaders(int contentLength) 43 | { 44 | var header = new StringBuilder(); 45 | 46 | header.AppendFormat("Content-Length: {0}\r\n", contentLength); 47 | header.Append("Content-Type: text/html; charset=UTF-8\r\n"); 48 | header.Append("\r\n"); 49 | 50 | return header.ToString(); 51 | } 52 | 53 | private string GetResponseContent() 54 | { 55 | var body = new StringBuilder(); 56 | 57 | body.Append(""); 58 | foreach (var parameter in this.Parameters) 59 | { 60 | body.Append(""); 61 | body.Append(""); 64 | body.Append(""); 67 | body.Append(""); 68 | } 69 | 70 | body.Append("
"); 62 | body.Append(parameter.Name); 63 | body.Append(""); 65 | body.Append(parameter.Value); 66 | body.Append("
"); 71 | 72 | return body.ToString(); 73 | } 74 | 75 | public override void Abort() 76 | { 77 | //TODO 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /FastCgi.Test/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /FastCgi.Test/log4net.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /FastCgi.Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /FastCgi.UnitTest/FastCgi.UnitTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {67219CCA-AEF5-499A-9580-36CFEFA3EEAF} 7 | Library 8 | Properties 9 | Grillisoft.FastCgi.UnitTest 10 | Grillisoft.FastCgi.UnitTest 11 | v4.5 12 | 512 13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 10.0 15 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 16 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages 17 | False 18 | UnitTest 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | true 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | {a3c516b6-046b-44c2-9387-2d01646589c9} 60 | FastCgi 61 | 62 | 63 | {afe9fdde-332c-41a5-8da5-6c974f9e6956} 64 | ImmutableArray 65 | 66 | 67 | 68 | 69 | 70 | 71 | False 72 | 73 | 74 | False 75 | 76 | 77 | False 78 | 79 | 80 | False 81 | 82 | 83 | 84 | 85 | 86 | 87 | 94 | -------------------------------------------------------------------------------- /FastCgi.UnitTest/ImmutableArrayTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 4 | 5 | namespace Grillisoft.FastCgi.UnitTest 6 | { 7 | [TestClass] 8 | public class ImmutableArrayTests 9 | { 10 | [TestMethod] 11 | public void Create() 12 | { 13 | var source = new byte[] { 1, 2, 3 }; 14 | var data = new ByteArray(source); 15 | 16 | Assert.IsTrue(data.Count == source.Length); 17 | Assert.IsTrue(data.Equals(source)); 18 | } 19 | 20 | [TestMethod] 21 | public void CopyTo() 22 | { 23 | var source = new byte[] { 1, 2, 3 }; 24 | var data = new ByteArray(source); 25 | var dest = new byte[3]; 26 | 27 | data.CopyTo(dest, 0); 28 | 29 | for (int i = 0; i < source.Length; i++) 30 | Assert.AreEqual(source[i], dest[i]); 31 | } 32 | 33 | [TestMethod] 34 | public void Concat() 35 | { 36 | var source1 = new byte[] { 1, 2, 3 }; 37 | var source2 = new byte[] { 4, 5, 6 }; 38 | 39 | var data = new ByteArray(source1).Concat(new ByteArray(source2)); 40 | 41 | for (int i = 0; i < source1.Length; i++) 42 | Assert.AreEqual(source1[i], data[i]); 43 | 44 | for (int i = 0; i < source2.Length; i++) 45 | Assert.AreEqual(source2[i], data[i + source1.Length]); 46 | } 47 | 48 | [TestMethod] 49 | public void SubArray() 50 | { 51 | var source = new byte[] { 1, 2, 3, 4, 5, 6 }; 52 | var data = new ByteArray(source).SubArray(2, 2, true); 53 | var dest = new byte[] { 3, 4 }; 54 | var wrong = new byte[] { 5, 6 }; 55 | 56 | Assert.IsTrue(data.Equals(dest)); 57 | Assert.IsFalse(data.Equals(wrong)); 58 | } 59 | 60 | [TestMethod] 61 | public void ConcatSubArray() 62 | { 63 | var source1 = new byte[] { 1, 2, 3 }; 64 | var source2 = new byte[] { 4, 5, 6 }; 65 | var source3 = new byte[] { 7, 8, 9 }; 66 | 67 | var data = new ByteArray(source1) 68 | .Concat(new ByteArray(source2)) 69 | .Concat(new ByteArray(source3)); 70 | 71 | var data2 = data.SubArray(2, 5); 72 | var ret = new byte[] { 3, 4, 5, 6, 7 }; 73 | 74 | Assert.IsTrue(data2.Count == ret.Length); 75 | Assert.IsTrue(data2.Equals(ret)); 76 | 77 | Assert.IsTrue(data2[3] == ret[3]); 78 | Assert.IsTrue(data2[4] != ret[3]); 79 | } 80 | 81 | [TestMethod] 82 | public void ConcatCopyTo() 83 | { 84 | var source1 = new byte[] { 1, 2, 3 }; 85 | var source2 = new byte[] { 4, 5, 6 }; 86 | var source3 = new byte[] { 7, 8, 9 }; 87 | 88 | var data = new ByteArray(source1) 89 | .Concat(new ByteArray(source2)) 90 | .Concat(new ByteArray(source3)); 91 | 92 | var dest = new byte[7]; 93 | 94 | data.CopyTo(dest, 0, dest.Length); 95 | 96 | using(var dataSub = data.SubArray(0, dest.Length)) 97 | { 98 | Assert.IsTrue(dataSub.Equals(dest)); 99 | } 100 | } 101 | 102 | [TestMethod] 103 | public void ToArray() 104 | { 105 | var source1 = new byte[] { 1, 2, 3 }; 106 | var source2 = new byte[] { 4, 5, 6 }; 107 | var source3 = new byte[] { 7, 8, 9 }; 108 | 109 | var data = new ByteArray(source1) 110 | .Concat(new ByteArray(source2)) 111 | .Concat(new ByteArray(source3)); 112 | 113 | var dest = data.ToArray(2, 5); 114 | var check = new byte[] { 3, 4, 5, 6, 7 }; 115 | 116 | Assert.AreEqual(dest.Length, check.Length); 117 | for (int i = 0; i < check.Length; i++) 118 | Assert.AreEqual(dest[i], check[i]); 119 | } 120 | 121 | [TestMethod] 122 | public void BufferManager() 123 | { 124 | var source = new byte[17342]; 125 | for(int i=0; i < source.Length; i++) 126 | { 127 | source[i] = (byte) (i % 255); 128 | } 129 | 130 | var data = new ByteArray(source); 131 | 132 | Assert.IsTrue(data.Count == source.Length); 133 | Assert.IsTrue(data.Equals(source)); 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /FastCgi.UnitTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FastCgi.UnitTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FastCgi.UnitTest")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("560b5e8f-f188-49d2-8d97-9319eb8f06dc")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FastCgi/FastCgi.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {A3C516B6-046B-44C2-9387-2D01646589C9} 9 | Library 10 | Properties 11 | Grillisoft.FastCgi 12 | Grillisoft.FastCgi 13 | v4.0 14 | 512 15 | false 16 | FastCgi.key 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | false 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | false 37 | true 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | {afe9fdde-332c-41a5-8da5-6c974f9e6956} 75 | ImmutableArray 76 | 77 | 78 | 79 | 80 | 81 | 82 | 90 | -------------------------------------------------------------------------------- /FastCgi/FastCgi.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gigi81/sharpfastcgi/e5aeead9f9be13e423067de2de876ba9821f81b2/FastCgi/FastCgi.key -------------------------------------------------------------------------------- /FastCgi/FastCgi.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | Luigi Grilli 7 | Luigi Grilli 8 | https://github.com/gigi81/sharpfastcgi/blob/master/LICENSE.txt 9 | https://github.com/gigi81/sharpfastcgi 10 | false 11 | FastCgi core library 12 | Initial nuget release 13 | Copyright 2018 Luigi Grilli 14 | fastcgi web server 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /FastCgi/IFastCgiChannelFactory.cs: -------------------------------------------------------------------------------- 1 | using Grillisoft.FastCgi.Protocol; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Grillisoft.FastCgi 8 | { 9 | public interface IFastCgiChannelFactory 10 | { 11 | /// 12 | /// Creates a new FastCgiChannel 13 | /// 14 | /// Lower used to communicate with the web server 15 | FastCgiChannel CreateChannel(ILowerLayer tcpLayer); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /FastCgi/IFastCgiServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Grillisoft.FastCgi 7 | { 8 | public interface IFastCgiServer 9 | { 10 | void Start(); 11 | 12 | void Stop(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /FastCgi/ILogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Grillisoft.FastCgi 7 | { 8 | public enum LogLevel 9 | { 10 | Critical, 11 | Error, 12 | Warning, 13 | Info, 14 | Verbose 15 | } 16 | 17 | public interface ILogger 18 | { 19 | void Log(LogLevel level, string format, params object[] args); 20 | 21 | void Log(LogLevel level, Exception ex, string format, params object[] args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /FastCgi/ILoggerFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Grillisoft.FastCgi 7 | { 8 | public interface ILoggerFactory 9 | { 10 | ILogger Create(Type type); 11 | 12 | ILogger Create(string name); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /FastCgi/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FastCgi")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FastCgi")] 13 | [assembly: AssemblyCopyright("Copyright © Luigi Grilli 2011 - 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1c7fd659-1f8c-4068-8ef9-b9b8ffb80bdd")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FastCgi/Protocol/ChannelProperties.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Linq; 28 | using System.Text; 29 | 30 | namespace Grillisoft.FastCgi.Protocol 31 | { 32 | public class ChannelProperties 33 | { 34 | public const string MaxConns = "FCGI_MAX_CONNS"; 35 | public const string MaxReqs = "FCGI_MAX_REQS"; 36 | public const string MpxsConns = "FCGI_MPXS_CONNS"; 37 | 38 | /// 39 | /// The maximum number of concurrent transport connections this application will accept, e.g. 1 or 10. 40 | /// 41 | public int MaximumConnections { get; set; } 42 | 43 | /// 44 | /// The maximum number of concurrent requests this application will accept, e.g. 1 or 50 45 | /// 46 | public int MaximumRequests { get; set; } 47 | 48 | /// 49 | /// Specify if this application does multiplex connections (i.e. handle concurrent requests over each connection) 50 | /// 51 | public bool SupportMultiplexedConnection { get; set; } 52 | 53 | /// 54 | /// Sets the values of the parameters specified in the collection 55 | /// 56 | /// Collection containg the parametes to set 57 | public void GetValues(NameValuePairCollection collection) 58 | { 59 | if (collection.ContainsKey(MaxConns)) 60 | collection.GetPair(MaxConns).Value = this.MaximumConnections.ToString(); 61 | 62 | if (collection.ContainsKey(MaxReqs)) 63 | collection.GetPair(MaxReqs).Value = this.MaximumRequests.ToString(); 64 | 65 | if (collection.ContainsKey(MpxsConns)) 66 | collection.GetPair(MpxsConns).Value = this.SupportMultiplexedConnection ? "1" : "0"; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /FastCgi/Protocol/ILayer.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Linq; 28 | using System.Text; 29 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 30 | 31 | namespace Grillisoft.FastCgi.Protocol 32 | { 33 | /// 34 | /// A protocol layer that receives data from a lower layer 35 | /// 36 | public interface IUpperLayer 37 | { 38 | /// 39 | /// Receives data from the lower layer 40 | /// 41 | /// Received data 42 | void Receive(ByteArray data); 43 | } 44 | 45 | /// 46 | /// A protocol layer that sends data received from an upper layer 47 | /// 48 | public interface ILowerLayer 49 | { 50 | /// 51 | /// Receives data from the upper layer 52 | /// 53 | /// Data to be sent 54 | void Send(ByteArray data); 55 | } 56 | 57 | /// 58 | /// A protocol layer that both sends and recives data 59 | /// 60 | public interface ILayer : IUpperLayer, ILowerLayer 61 | { 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /FastCgi/Protocol/IRequestsRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Grillisoft.FastCgi.Protocol 7 | { 8 | public interface IRequestsRepository 9 | { 10 | void AddRequest(Request request); 11 | 12 | void RemoveRequest(Request request); 13 | 14 | Request GetRequest(ushort requestId); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /FastCgi/Protocol/Message.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 27 | 28 | namespace Grillisoft.FastCgi.Protocol 29 | { 30 | public class Message 31 | { 32 | public static readonly byte[] Padding = new byte[Consts.ChunkSize]; 33 | 34 | public Message(ByteArray array) 35 | { 36 | this.Header = new MessageHeader(array); 37 | this.Body = array.SubArray(MessageHeader.HeaderSize, this.Header.ContentLength); 38 | } 39 | 40 | public Message(byte[] data) 41 | : this(new ByteArray(data)) 42 | { 43 | } 44 | 45 | protected Message(MessageHeader header) 46 | : this(header, ByteArray.Empty) 47 | { 48 | } 49 | 50 | public Message(MessageType messageType, ushort requestId, byte[] body) 51 | : this(messageType, requestId, new ByteArray(body)) 52 | { 53 | } 54 | 55 | public Message(MessageType messageType, ushort requestId, ByteArray body) 56 | : this(new MessageHeader(messageType, requestId, (ushort)body.Count), body) 57 | { 58 | } 59 | 60 | public Message(MessageHeader header, ByteArray body) 61 | { 62 | if (header.ContentLength != body.Count) 63 | throw new InvalidOperationException("Header ContentLength must be equals to body length"); 64 | 65 | this.Header = header; 66 | this.Body = body; 67 | } 68 | 69 | public MessageHeader Header { get; protected set; } 70 | 71 | public ByteArray Body { get; protected set; } 72 | 73 | public int CopyTo(byte[] dest) 74 | { 75 | if (dest.Length < this.Header.MessageSize) 76 | throw new ArgumentException("dest"); 77 | 78 | this.Header.CopyTo(dest); 79 | this.Body.CopyTo(dest, MessageHeader.HeaderSize); 80 | Array.Copy(Padding, 0, dest, MessageHeader.HeaderSize + this.Body.Count, this.Header.PaddingLength); 81 | 82 | return this.Header.MessageSize; 83 | } 84 | 85 | public ByteArray ToByteArray() 86 | { 87 | return new ByteArray(this.Header.ToArray()) + this.Body + new ByteArray(Padding, this.Header.PaddingLength); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /FastCgi/Protocol/MessageBody.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Text; 27 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 28 | 29 | namespace Grillisoft.FastCgi.Protocol 30 | { 31 | public struct BeginRequestMessageBody 32 | { 33 | public FastCgiRoles Role; 34 | public byte Flags; 35 | public byte[] Reserved; 36 | 37 | public BeginRequestMessageBody(FastCgiRoles role) 38 | { 39 | Role = role; 40 | Flags = 0x00; 41 | Reserved = new byte[5]; 42 | } 43 | 44 | public BeginRequestMessageBody(ByteArray body) 45 | { 46 | Role = (FastCgiRoles)Utils.ReadUint16(body, 0); 47 | Flags = body[2]; 48 | Reserved = body.ToArray(3, body.Count - 3); 49 | } 50 | 51 | /// 52 | /// If false, the application closes the connection after responding to this request. 53 | /// If true, the application does not close the connection after responding to this request; 54 | /// the Web server retains responsibility for the connection. 55 | /// 56 | public bool KeepConnection { get { return (this.Flags & 0x01) != 0; } } 57 | } 58 | 59 | public struct EndRequestMessageBody 60 | { 61 | /// 62 | /// Application Status 63 | /// 64 | public int ApplicationStatus; 65 | /// 66 | /// Protocol Status 67 | /// 68 | public ProtocolStatus ProtocolStatus; 69 | /// 70 | /// Reseved for future use and body padding 71 | /// 72 | public byte[] Reserved; 73 | 74 | public EndRequestMessageBody(int appStatus, ProtocolStatus protocolStatus) 75 | { 76 | ApplicationStatus = appStatus; 77 | ProtocolStatus = protocolStatus; 78 | Reserved = new byte[3]; 79 | } 80 | 81 | public void CopyTo(byte[] dest) 82 | { 83 | this.CopyTo(dest, 0); 84 | } 85 | 86 | public void CopyTo(byte[] body, int startIndex) 87 | { 88 | body[startIndex + 0] = (byte) ((this.ApplicationStatus >> 24) & 0xFF); 89 | body[startIndex + 1] = (byte) ((this.ApplicationStatus >> 16) & 0xFF); 90 | body[startIndex + 2] = (byte) ((this.ApplicationStatus >> 8) & 0xFF); 91 | body[startIndex + 3] = (byte) ((this.ApplicationStatus) & 0xFF); 92 | body[startIndex + 4] = (byte) this.ProtocolStatus; 93 | body[startIndex + 5] = this.Reserved[0]; 94 | body[startIndex + 6] = this.Reserved[1]; 95 | body[startIndex + 7] = this.Reserved[2]; 96 | } 97 | 98 | public byte[] ToArray() 99 | { 100 | var ret = new byte[Consts.ChunkSize]; 101 | this.CopyTo(ret); 102 | return ret; 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /FastCgi/Protocol/MessageHeader.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Linq; 28 | using System.Text; 29 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 30 | 31 | namespace Grillisoft.FastCgi.Protocol 32 | { 33 | public struct MessageHeader 34 | { 35 | /// 36 | /// Record header size in bytes 37 | /// 38 | public const ushort HeaderSize = Consts.ChunkSize; 39 | 40 | /// 41 | /// FastCGI version number 42 | /// 43 | public byte Version; 44 | 45 | /// 46 | /// Record type 47 | /// 48 | public MessageType MessageType; 49 | 50 | /// 51 | /// Request ID 52 | /// 53 | public ushort RequestId; 54 | 55 | /// 56 | /// Content length 57 | /// 58 | public ushort ContentLength; 59 | 60 | /// 61 | /// Length of record padding 62 | /// 63 | public byte PaddingLength; 64 | 65 | /// 66 | /// Reseved for future use and header padding 67 | /// 68 | public byte Reserved; 69 | 70 | public MessageHeader(MessageType messageType, ushort requestId, ushort contentLength) 71 | { 72 | Version = Consts.Version; 73 | MessageType = messageType; 74 | RequestId = requestId; 75 | ContentLength = contentLength; 76 | PaddingLength = CalculatePadding(contentLength); 77 | Reserved = 0x00; 78 | } 79 | 80 | public MessageHeader(ByteArray array) 81 | : this(array.ToArray(0, HeaderSize)) 82 | { 83 | } 84 | 85 | public MessageHeader(byte[] header) 86 | : this(header, 0) 87 | { 88 | } 89 | 90 | public MessageHeader(byte[] header, int startIndex) 91 | { 92 | Version = header[startIndex + 0]; 93 | MessageType = (MessageType)header[startIndex + 1]; 94 | RequestId = Utils.ReadUint16(header, startIndex + 2); 95 | ContentLength = Utils.ReadUint16(header, startIndex + 4); 96 | PaddingLength = header[startIndex + 6]; 97 | Reserved = header[startIndex + 7]; 98 | } 99 | 100 | public RecordType RecordType 101 | { 102 | get 103 | { 104 | return (this.RequestId == 0) ? RecordType.Management : RecordType.Application; 105 | } 106 | } 107 | 108 | /// 109 | /// Size of the entire message complete with header, content and padding 110 | /// 111 | public int MessageSize 112 | { 113 | get 114 | { 115 | return HeaderSize + this.ContentLength + this.PaddingLength; 116 | } 117 | } 118 | 119 | public void CopyTo(byte[] dest) 120 | { 121 | this.CopyTo(dest, 0); 122 | } 123 | 124 | public void CopyTo(byte[] header, int startIndex) 125 | { 126 | header[startIndex + 0] = Version; 127 | header[startIndex + 1] = (byte) MessageType; 128 | header[startIndex + 2] = (byte) ((RequestId >> 8) & 0xFF); 129 | header[startIndex + 3] = (byte) (RequestId & 0xFF); 130 | header[startIndex + 4] = (byte) ((ContentLength >> 8) & 0xFF); 131 | header[startIndex + 5] = (byte) (ContentLength & 0xFF); 132 | header[startIndex + 6] = PaddingLength; 133 | header[startIndex + 7] = Reserved; 134 | } 135 | 136 | public byte[] ToArray() 137 | { 138 | var ret = new byte[HeaderSize]; 139 | this.CopyTo(ret); 140 | return ret; 141 | } 142 | 143 | private static byte CalculatePadding(ushort contentLength) 144 | { 145 | if (contentLength % Consts.ChunkSize == 0) 146 | return 0; 147 | 148 | return (byte)(Consts.ChunkSize - (contentLength % Consts.ChunkSize)); 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /FastCgi/Protocol/NameValuePair.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.IO; 27 | using System.Text; 28 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 29 | 30 | namespace Grillisoft.FastCgi.Protocol 31 | { 32 | public class NameValuePair 33 | { 34 | public string Name { get; set; } 35 | 36 | public string Value { get; set; } 37 | 38 | public NameValuePair() 39 | { 40 | } 41 | 42 | public NameValuePair(BinaryReader reader) 43 | { 44 | int nameLength = GetLength(reader); 45 | int valueLength = GetLength(reader); 46 | 47 | this.Name = Encoding.UTF8.GetString(reader.ReadBytes(nameLength)); 48 | this.Value = Encoding.UTF8.GetString(reader.ReadBytes(valueLength)); 49 | } 50 | 51 | public void Encode(BinaryWriter writer) 52 | { 53 | byte[] name = Encoding.UTF8.GetBytes(this.Name); 54 | byte[] value = Encoding.UTF8.GetBytes(this.Value); 55 | 56 | writer.Write(SetLength(name.Length)); 57 | writer.Write(SetLength(value.Length)); 58 | writer.Write(name); 59 | writer.Write(value); 60 | } 61 | 62 | public static int GetLength(BinaryReader reader) 63 | { 64 | byte length = reader.ReadByte(); 65 | if ((length & 0x80) == 0) 66 | return length; 67 | 68 | return ((length & 0x7F) << 24) + 69 | (reader.ReadByte() << 16) + 70 | (reader.ReadByte() << 8) + 71 | (reader.ReadByte()); 72 | } 73 | 74 | public static byte[] SetLength(int length) 75 | { 76 | if (length <= 0x7F) 77 | return new[] {(byte) length}; 78 | 79 | return new[] { 80 | (byte)((length >> 24) & 0x7F), 81 | (byte)(length >> 16 & 0xFF), 82 | (byte)(length >> 8 & 0xFF), 83 | (byte)(length & 0xFF) 84 | }; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /FastCgi/Protocol/NameValuePairCollection.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections; 27 | using System.Collections.Generic; 28 | using System.IO; 29 | using System.Text; 30 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 31 | 32 | 33 | namespace Grillisoft.FastCgi.Protocol 34 | { 35 | public class NameValuePairCollection : IEnumerable 36 | { 37 | private Dictionary _dictionary = new Dictionary(); 38 | 39 | public NameValuePairCollection() 40 | { 41 | } 42 | 43 | public NameValuePairCollection(Stream stream) 44 | { 45 | using (BinaryReader reader = new BinaryReader(stream, Encoding.UTF8)) 46 | { 47 | this.ReadCollection(reader); 48 | } 49 | } 50 | 51 | private void ReadCollection(BinaryReader reader) 52 | { 53 | var stream = reader.BaseStream; 54 | 55 | while (stream.Position < stream.Length /* check for stream EOF */) 56 | { 57 | try 58 | { 59 | this.Add(new NameValuePair(reader)); 60 | } 61 | catch (EndOfStreamException) 62 | { 63 | break; //exit loop 64 | } 65 | } 66 | } 67 | 68 | public string GetValue(string name) 69 | { 70 | NameValuePair ret; 71 | return _dictionary.TryGetValue(name, out ret) ? ret.Value : null; 72 | } 73 | 74 | public NameValuePair GetPair(string name) 75 | { 76 | NameValuePair ret; 77 | return _dictionary.TryGetValue(name, out ret) ? ret : null; 78 | } 79 | 80 | public void Add(NameValuePair pair) 81 | { 82 | _dictionary.Add(pair.Name, pair); 83 | } 84 | 85 | public void Add(IEnumerable collection) 86 | { 87 | foreach (NameValuePair item in collection) 88 | this.Add(item); 89 | } 90 | 91 | public int Count 92 | { 93 | get { return _dictionary.Count; } 94 | } 95 | 96 | public bool ContainsKey(string name) 97 | { 98 | return _dictionary.ContainsKey(name); 99 | } 100 | 101 | #region IEnumerable implementation 102 | public IEnumerator GetEnumerator() 103 | { 104 | return _dictionary.Values.GetEnumerator(); 105 | } 106 | 107 | IEnumerator IEnumerable.GetEnumerator() 108 | { 109 | return _dictionary.Values.GetEnumerator(); 110 | } 111 | #endregion 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /FastCgi/Protocol/OutputStream.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.IO; 28 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 29 | 30 | namespace Grillisoft.FastCgi.Protocol 31 | { 32 | /// 33 | /// Output stream to write data to 34 | /// 35 | public class OutputStream : Stream 36 | { 37 | private MemoryStream _cache = new MemoryStream(256); 38 | 39 | public event EventHandler Flushing; 40 | 41 | private ByteArray _array = ByteArray.Empty; 42 | 43 | public OutputStream() 44 | { 45 | } 46 | 47 | public override bool CanRead 48 | { 49 | get { return false; } 50 | } 51 | 52 | public override bool CanSeek 53 | { 54 | get { return false; } 55 | } 56 | 57 | public override bool CanWrite 58 | { 59 | get { return true; } 60 | } 61 | 62 | public override void Flush() 63 | { 64 | this.WriteCache(); 65 | 66 | if (_array.Count <= 0) 67 | return; //nothing to flush 68 | 69 | if (this.Flushing != null) 70 | this.Flushing(this, new FlushEventArgs(_array)); 71 | 72 | _array.Dispose(); 73 | _array = ByteArray.Empty; 74 | } 75 | 76 | public override long Length 77 | { 78 | get { return _array.Count; } 79 | } 80 | 81 | public override long Position { get; /* TODO: add setter checks */ set; } 82 | 83 | public override int Read(byte[] buffer, int offset, int count) 84 | { 85 | throw new NotSupportedException(); 86 | } 87 | 88 | public override long Seek(long offset, SeekOrigin origin) 89 | { 90 | throw new NotSupportedException(); 91 | } 92 | 93 | public override void SetLength(long value) 94 | { 95 | throw new NotSupportedException(); 96 | } 97 | 98 | /// 99 | /// Free space in cache 100 | /// 101 | private int FreeCache 102 | { 103 | get { return _cache.Capacity - (int)_cache.Length; } 104 | } 105 | 106 | public override void Write(byte[] buffer, int offset, int count) 107 | { 108 | if (count <= this.FreeCache) 109 | { 110 | _cache.Write(buffer, offset, count); 111 | } 112 | else 113 | { 114 | this.WriteCache(); 115 | _array = _array.Concat(new ByteArray(buffer, count, offset), true); 116 | } 117 | } 118 | 119 | private void WriteCache() 120 | { 121 | if (_cache.Length <= 0) 122 | return; 123 | 124 | _array = _array.Concat(new ByteArray(_cache.ToArray()), true); 125 | _cache.SetLength(0); 126 | } 127 | } 128 | 129 | public class FlushEventArgs : EventArgs 130 | { 131 | public FlushEventArgs(ByteArray data) 132 | { 133 | this.Data = data; 134 | } 135 | 136 | public ByteArray Data { get; private set; } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /FastCgi/Protocol/Request.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Linq; 28 | using System.Text; 29 | using System.IO; 30 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 31 | 32 | namespace Grillisoft.FastCgi.Protocol 33 | { 34 | public abstract class Request 35 | { 36 | public event EventHandler Ended; 37 | public event EventHandler OutputFlushing; 38 | public event EventHandler ErrorFlushing; 39 | 40 | private NameValuePairCollection _parameters = null; 41 | 42 | protected Request(ushort id, BeginRequestMessageBody body) 43 | { 44 | this.Id = id; 45 | this.RequestBody = body; 46 | this.ExitCode = 0; 47 | 48 | this.ParametersStream = new InputStream(); 49 | this.InputStream = new InputStream(); 50 | this.DataStream = new InputStream(); 51 | 52 | this.OutputStream = new OutputStream(); 53 | this.ErrorStream = new OutputStream(); 54 | 55 | this.OutputStream.Flushing += new EventHandler(OutputStreamFlushing); 56 | this.ErrorStream.Flushing += new EventHandler(ErrorStreamFlushing); 57 | } 58 | 59 | private void ErrorStreamFlushing(object sender, FlushEventArgs e) 60 | { 61 | this.OnErrorStreamFlushing(e); 62 | } 63 | 64 | private void OutputStreamFlushing(object sender, FlushEventArgs e) 65 | { 66 | this.OnOutputStreamFlushing(e); 67 | } 68 | 69 | public ushort Id { get; protected set; } 70 | 71 | public BeginRequestMessageBody RequestBody { get; protected set; } 72 | 73 | public int ExitCode { get; protected set; } 74 | 75 | public NameValuePairCollection Parameters 76 | { 77 | get 78 | { 79 | if(_parameters == null) 80 | _parameters = new NameValuePairCollection(this.ParametersStream); 81 | 82 | return _parameters; 83 | } 84 | } 85 | 86 | public InputStream ParametersStream { get; protected set; } 87 | 88 | public InputStream InputStream { get; protected set; } 89 | 90 | public InputStream DataStream { get; protected set; } 91 | 92 | public OutputStream OutputStream { get; protected set; } 93 | 94 | public OutputStream ErrorStream { get; protected set; } 95 | 96 | public abstract void Execute(); 97 | 98 | public abstract void Abort(); 99 | 100 | /// 101 | /// Ends the request 102 | /// 103 | public void End() 104 | { 105 | this.OutputStream.Flush(); 106 | this.ErrorStream.Flush(); 107 | 108 | if (this.Ended != null) 109 | this.Ended(this, EventArgs.Empty); 110 | } 111 | 112 | protected virtual void OnOutputStreamFlushing(FlushEventArgs args) 113 | { 114 | if (this.OutputFlushing != null) 115 | this.OutputFlushing(this, args); 116 | } 117 | 118 | protected virtual void OnErrorStreamFlushing(FlushEventArgs args) 119 | { 120 | if (this.ErrorFlushing != null) 121 | this.ErrorFlushing(this, args); 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /FastCgi/Protocol/SimpleFastCgiChannel.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Linq; 28 | using System.Text; 29 | 30 | namespace Grillisoft.FastCgi.Protocol 31 | { 32 | /// 33 | /// A that can handle only one request at a time 34 | /// 35 | /// Request type handled by the channel 36 | public abstract class SimpleFastCgiChannel : FastCgiChannel 37 | { 38 | public SimpleFastCgiChannel(ILowerLayer layer, ILoggerFactory loggerFactory) 39 | : base(layer, new Repositories.SingleRequestRepository(), loggerFactory) 40 | { 41 | this.Properties = new Protocol.ChannelProperties() 42 | { 43 | MaximumConnections = 1, 44 | MaximumRequests = 1, 45 | SupportMultiplexedConnection = false 46 | }; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /FastCgi/Repositories/RequestsRepository.cs: -------------------------------------------------------------------------------- 1 | using Grillisoft.FastCgi.Protocol; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Grillisoft.FastCgi.Repositories 8 | { 9 | public class RequestsRepository : IRequestsRepository 10 | { 11 | private readonly Dictionary _requests = new Dictionary(); 12 | 13 | public void AddRequest(Protocol.Request request) 14 | { 15 | _requests.Add(request.Id, request); 16 | } 17 | 18 | public void RemoveRequest(Protocol.Request request) 19 | { 20 | _requests.Remove(request.Id); 21 | } 22 | 23 | public Protocol.Request GetRequest(ushort requestId) 24 | { 25 | return _requests[requestId]; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /FastCgi/Repositories/SingleRequestRepository.cs: -------------------------------------------------------------------------------- 1 | using Grillisoft.FastCgi.Protocol; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Grillisoft.FastCgi.Repositories 8 | { 9 | public class SingleRequestRepository : IRequestsRepository 10 | { 11 | private Request _request; 12 | 13 | public void AddRequest(Request request) 14 | { 15 | _request = request; 16 | } 17 | 18 | public void RemoveRequest(Request request) 19 | { 20 | _request = null; 21 | } 22 | 23 | public Request GetRequest(ushort requestId) 24 | { 25 | return _request; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /FastCgi/Repositories/SyncronizedRequestsRepository.cs: -------------------------------------------------------------------------------- 1 | using Grillisoft.FastCgi.Protocol; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Grillisoft.FastCgi.Repositories 8 | { 9 | public class SyncronizedRequestsRepository : IRequestsRepository 10 | { 11 | private readonly Dictionary _requests = new Dictionary(); 12 | 13 | public void AddRequest(Protocol.Request request) 14 | { 15 | lock(_requests) 16 | { 17 | _requests.Add(request.Id, request); 18 | } 19 | } 20 | 21 | public void RemoveRequest(Protocol.Request request) 22 | { 23 | lock(_requests) 24 | { 25 | _requests.Remove(request.Id); 26 | } 27 | } 28 | 29 | public Protocol.Request GetRequest(ushort requestId) 30 | { 31 | lock(_requests) 32 | { 33 | return _requests[requestId]; 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /FastCgi/Servers/ITcpServerConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | 7 | namespace Grillisoft.FastCgi.Servers 8 | { 9 | public interface ITcpServerConfig 10 | { 11 | IPAddress Address { get; } 12 | 13 | int Port { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /FastCgi/Servers/IisServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | using System.IO.Pipes; 7 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 8 | using Grillisoft.FastCgi.Protocol; 9 | using System.Threading; 10 | using System.Diagnostics; 11 | using System.Runtime.InteropServices; 12 | using Microsoft.Win32.SafeHandles; 13 | using System.IO; 14 | 15 | namespace Grillisoft.FastCgi.Servers 16 | { 17 | public class IisServer : IFastCgiServer, ILowerLayer 18 | { 19 | private readonly Stream _server; 20 | private readonly Thread _thread; 21 | private readonly IFastCgiChannelFactory _channelFactory; 22 | private readonly ILogger _logger; 23 | private readonly byte[] _recvBuffer = new byte[4096]; 24 | private readonly byte[] _sendBuffer = new byte[4096]; 25 | private bool _running = false; 26 | 27 | //private readonly Regex ParsePath = new Regex(@"\\\\([^\\]+)\\pipe\\([^\\]+)"); 28 | 29 | private const uint STD_INPUT_HANDLE = 0xfffffff6; 30 | private const uint STD_OUTPUT_HANDLE = 0xfffffff5; 31 | private const uint STD_ERROR_HANDLE = 0xfffffff4; 32 | 33 | [DllImport("kernel32.dll")] 34 | private static extern IntPtr GetStdHandle(uint nStdHandle); 35 | 36 | private static IntPtr StandardInputHandle { get { return GetStdHandle(STD_INPUT_HANDLE); } } 37 | 38 | public IisServer(IFastCgiChannelFactory channelFactory, ILoggerFactory loggerFactory) 39 | { 40 | var handle = new SafeFileHandle(StandardInputHandle, true); 41 | 42 | _channelFactory = channelFactory; 43 | _logger = loggerFactory.Create(this.GetType()); 44 | 45 | _server = new FileStream(handle, FileAccess.ReadWrite, 4096, false); 46 | _thread = new Thread(this.Run); 47 | } 48 | 49 | /// 50 | /// Upper layer to send data received from tcp channel 51 | /// 52 | public IUpperLayer UpperLayer { get; set; } 53 | 54 | public void Start() 55 | { 56 | _logger.Log(LogLevel.Info, "Starting IIS server"); 57 | _running = true; 58 | _thread.Start(); 59 | } 60 | 61 | public void Stop() 62 | { 63 | _logger.Log(LogLevel.Info, "Stopping IIS server"); 64 | _running = false; 65 | _thread.Abort(); 66 | } 67 | 68 | private void Run() 69 | { 70 | try 71 | { 72 | this.UpperLayer = _channelFactory.CreateChannel(this); 73 | 74 | int read = 0; 75 | 76 | while (_running && read >= 0) 77 | { 78 | read = _server.Read(_recvBuffer, 0, _recvBuffer.Length); 79 | if (read > 0) 80 | this.UpperLayer.Receive(new ByteArray(_recvBuffer, (int)read)); 81 | } 82 | } 83 | finally 84 | { 85 | _server.Close(); 86 | } 87 | } 88 | 89 | public void Send(ByteArray data) 90 | { 91 | lock(_sendBuffer) 92 | { 93 | while (data.Count > 0) 94 | { 95 | int length = Math.Min(data.Count, _sendBuffer.Length); 96 | 97 | data.CopyTo(_sendBuffer, 0, length); 98 | _server.Write(_sendBuffer, 0, length); 99 | data = data.SubArray(length, true); 100 | } 101 | 102 | _server.Flush(); 103 | } 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /FastCgi/Servers/TcpLayer.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Net.Sockets; 28 | using Grillisoft.FastCgi.Protocol; 29 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 30 | using Grillisoft.ImmutableArray; 31 | 32 | namespace Grillisoft.FastCgi.Servers 33 | { 34 | internal class TcpLayer : ILowerLayer, IDisposable 35 | { 36 | public event EventHandler RunError; 37 | 38 | private readonly TcpClient _client; 39 | private readonly byte[] _recvBuffer = new byte[4096]; 40 | private readonly byte[] _sendBuffer = new byte[4096]; 41 | 42 | public TcpLayer(TcpClient client) 43 | { 44 | _client = client; 45 | } 46 | 47 | /// 48 | /// Upper layer to send data received from tcp channel 49 | /// 50 | public IUpperLayer UpperLayer { get; set; } 51 | 52 | /// 53 | /// Continuously calls the method of the while the socket is connected 54 | /// 55 | /// This is a blocking call. When exiting this call the socket will be already closed 56 | public void Run() 57 | { 58 | try 59 | { 60 | while (_client.Connected) 61 | { 62 | //blocking call 63 | int read = _client.GetStream().Read(_recvBuffer, 0, _recvBuffer.Length); 64 | if (read > 0) 65 | { 66 | //Console.WriteLine("received {0} bytes", read); 67 | this.UpperLayer.Receive(new ByteArray(_recvBuffer, read)); 68 | } 69 | } 70 | } 71 | catch (Exception ex) 72 | { 73 | this.OnRunError(new UnhandledExceptionEventArgs(ex, false)); 74 | } 75 | finally 76 | { 77 | _client.Close(); 78 | } 79 | 80 | Console.WriteLine("Tcp layer loop completed"); 81 | } 82 | 83 | /// 84 | /// Sends data to the network 85 | /// 86 | /// Data to send 87 | public void Send(ByteArray data) 88 | { 89 | lock (_sendBuffer) 90 | { 91 | while (data.Count > 0) 92 | { 93 | int length = Math.Min(data.Count, _sendBuffer.Length); 94 | 95 | data.CopyTo(_sendBuffer, 0, length); 96 | _client.GetStream().Write(_sendBuffer, 0, length); 97 | _client.GetStream().Flush(); 98 | //Console.WriteLine("sent {0} bytes", length); 99 | data = data.SubArray(length, true); 100 | } 101 | } 102 | } 103 | 104 | public void Close() 105 | { 106 | if(_client.Connected) 107 | { 108 | _client.Client.Disconnect(true); 109 | _client.Close(); 110 | } 111 | } 112 | 113 | protected virtual void OnRunError(UnhandledExceptionEventArgs args) 114 | { 115 | if (this.RunError != null) 116 | this.RunError(this, args); 117 | } 118 | 119 | public void Dispose() 120 | { 121 | this.Close(); 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /FastCgi/Utils.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2012-2014 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Linq; 28 | using System.Text; 29 | using ByteArray = Grillisoft.ImmutableArray.ImmutableArray; 30 | 31 | namespace Grillisoft.FastCgi 32 | { 33 | internal static class Utils 34 | { 35 | /// 36 | /// Reads a from the specified 37 | /// 38 | /// 39 | /// 40 | /// 41 | internal static ushort ReadUint16(ByteArray data, int offset) 42 | { 43 | return (ushort)((data[offset] << 8) + data[offset + 1]); 44 | } 45 | 46 | /// 47 | /// Reads a from the specified 48 | /// 49 | /// 50 | /// 51 | /// 52 | internal static ushort ReadUint16(byte[] data, int offset) 53 | { 54 | return (ushort)((data[offset] << 8) + data[offset + 1]); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ImmutableArray/BufferManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Grillisoft.ImmutableArray 7 | { 8 | internal class BufferManager : IBufferManager where T : struct, IComparable, IEquatable, IConvertible 9 | { 10 | public const int DefaultSize = 4096; 11 | 12 | /// 13 | /// Contains the list of the buffers in use 14 | /// 15 | private readonly HashSet _buffers = new HashSet(); 16 | 17 | /// 18 | /// Contains the list of the buffers NOT in use 19 | /// 20 | private readonly Stack _freeBuffers = new Stack(); 21 | 22 | /// 23 | /// Oject used to syncronise access to the BufferManager 24 | /// 25 | private readonly object _sync = new object(); 26 | 27 | private int _count = 0; 28 | 29 | public void Init(int count) 30 | { 31 | lock (_sync) 32 | { 33 | while (count > 0) 34 | { 35 | _freeBuffers.Push(this.CreateMutableBuffer()); 36 | count--; 37 | } 38 | } 39 | } 40 | 41 | /// 42 | /// The total number of elements managed 43 | /// 44 | public long Size 45 | { 46 | get { return DefaultSize*_count; } 47 | } 48 | 49 | /// 50 | /// The total number of elements free 51 | /// 52 | public long FreeSize 53 | { 54 | get 55 | { 56 | lock (_sync) 57 | { 58 | return _freeBuffers.Count*DefaultSize; 59 | } 60 | } 61 | } 62 | 63 | /// 64 | /// Allocates and return the arrays for a total of elements 65 | /// 66 | /// The total size of the arrays to return 67 | /// 68 | public IEnumerable Allocate(int size) 69 | { 70 | while (size > 0) 71 | { 72 | var ret = this.Allocate(); 73 | size -= ret.Length; 74 | yield return ret; 75 | } 76 | } 77 | 78 | public T[] Allocate() 79 | { 80 | lock (_sync) 81 | { 82 | return GetFreeBuffer() ?? AllocateInternal(); 83 | } 84 | } 85 | 86 | public void Free(T[] data) 87 | { 88 | lock (_sync) 89 | { 90 | if (!_buffers.Contains(data)) 91 | throw new Exception("Buffer specified was already freed or is not managed"); 92 | 93 | _freeBuffers.Push(data); 94 | _buffers.Remove(data); 95 | } 96 | } 97 | 98 | private T[] AllocateInternal() 99 | { 100 | var ret = this.CreateMutableBuffer(); 101 | _buffers.Add(ret); 102 | return ret; 103 | } 104 | 105 | private T[] GetFreeBuffer() 106 | { 107 | var ret = _freeBuffers.Count <= 0 ? null : _freeBuffers.Pop(); 108 | if (ret != null) 109 | _buffers.Add(ret); 110 | 111 | return ret; 112 | } 113 | 114 | private T[] CreateMutableBuffer() 115 | { 116 | var ret = new T[DefaultSize]; 117 | _count++; 118 | return ret; 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /ImmutableArray/IBufferManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Grillisoft.ImmutableArray 7 | { 8 | public interface IBufferManager where T : struct, IComparable, IEquatable, IConvertible 9 | { 10 | /// 11 | /// Allocates and return the arrays for a total of elements 12 | /// 13 | /// The total size of the arrays to return 14 | /// 15 | IEnumerable Allocate(int length); 16 | 17 | void Free(T[] data); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ImmutableArray/ImmutableArray.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {AFE9FDDE-332C-41A5-8DA5-6C974F9E6956} 8 | Library 9 | Properties 10 | Grillisoft.ImmutableArray 11 | Grillisoft.ImmutableArray 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 55 | -------------------------------------------------------------------------------- /ImmutableArray/ImmutableArray.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | Luigi Grilli 7 | Luigi Grilli 8 | https://github.com/gigi81/sharpfastcgi/blob/master/LICENSE.txt 9 | https://github.com/gigi81/sharpfastcgi 10 | false 11 | FastCgi Immutable Array library 12 | Initial nuget release 13 | Copyright 2018 Luigi Grilli 14 | fastcgi web server immutable array 15 | 16 | -------------------------------------------------------------------------------- /ImmutableArray/ImmutableArrayEnumerator.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | //*****************************************************************************/ 3 | // Copyright (c) 2010 - 2012 Luigi Grilli 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | //*****************************************************************************/ 23 | #endregion 24 | 25 | using System; 26 | using System.Collections; 27 | using System.Collections.Generic; 28 | using System.Text; 29 | 30 | namespace Grillisoft.ImmutableArray 31 | { 32 | internal class ImmutableArrayEnumerator : IEnumerator where T : struct, IComparable, IEquatable, IConvertible 33 | { 34 | private readonly List> _arrays = null; 35 | private int _arrayIndex = 0; 36 | private int _index = -1; 37 | 38 | public ImmutableArrayEnumerator(List> arrays) 39 | { 40 | _arrays = arrays; 41 | } 42 | 43 | #region IEnumerator Membri di 44 | 45 | public T Current 46 | { 47 | get { return _arrays[_arrayIndex][_index]; } 48 | } 49 | 50 | #endregion 51 | 52 | #region IDisposable Membri di 53 | 54 | public void Dispose() 55 | { 56 | } 57 | 58 | #endregion 59 | 60 | #region IEnumerator Membri di 61 | 62 | object IEnumerator.Current 63 | { 64 | get { return this.Current; } 65 | } 66 | 67 | public bool MoveNext() 68 | { 69 | _index++; 70 | 71 | if (_index < _arrays[_arrayIndex].Length) 72 | return true; 73 | 74 | _arrayIndex++; 75 | _index = 0; 76 | 77 | return _arrayIndex < _arrays.Count && _index < _arrays[_arrayIndex].Length; 78 | } 79 | 80 | public void Reset() 81 | { 82 | _index = -1; 83 | _arrayIndex = 0; 84 | } 85 | #endregion 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /ImmutableArray/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ImmutableArray")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ImmutableArray")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1bfa5016-17ed-4ccb-8cdb-3b75a9903c9e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Luigi Grilli 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://ci.appveyor.com/api/projects/status/01w5s07237opjnj3?svg=true)](https://ci.appveyor.com/project/gigi81/sharpfastcgi) 2 | 3 | sharpfastcgi 4 | ============ 5 | 6 | C# fastcgi protocol implementation plus some usage examples. 7 | A good example on how to self-host your web application without the need of IIS or Mono. 8 | 9 | The purpose of this implementation is to have a more reliable solution than the one 10 | offered with Mono and also a cleaner and reusable implementation of the protocol 11 | to host not only ASP.NET applications but also custom low level (and fast) applications, 12 | the ones that usually are implemented with an HttpListener. 13 | With this implementation is possible for example to host an ASP.NET application (also MVC) 14 | with and Nginx web-server on both Windows and Linux. 15 | 16 | Installing via NuGet 17 | ============ 18 | 19 | The easiest way to install FastCgi core library is via [NuGet](https://www.nuget.org/packages/Grillisoft.FastCgi/). 20 | 21 | In Visual Studio's [Package Manager Console](http://docs.nuget.org/docs/start-here/using-the-package-manager-console), 22 | enter the following command: 23 | 24 | ``` 25 | Install-Package Grillisoft.FastCgi 26 | ``` 27 | 28 | To add logging using log4net: 29 | 30 | ``` 31 | Install-Package Grillisoft.FastCgi.Loggers.Log4Net 32 | ``` 33 | 34 | To host an aspnet website: 35 | 36 | ``` 37 | Install-Package Grillisoft.FastCgi.AspNet 38 | ``` 39 | 40 | Example (Nginx) 41 | ============ 42 | You can run the first example/test following this procedure: 43 | 44 | 1. Build the solution (Debug | Mixed Platforms) 45 | 2. For Windows, 46 | a. Create the folders `.\Examples\windows-nginx-1.6.2\logs`and `.\Examples\windows-nginx-1.6.2\temp` 47 | b. Run `.\Examples\windows-nginx-1.6.2\nginx.exe`. 48 | For Linux, run nginx with the configuration supplied with the Windows example. 49 | 3. Run `.\FastCgi.Server\bin\Debug\Grillisoft.FastCgi.Server.exe`. 50 | 4. In your browser, go to http://localhost:8082/info.aspx or http://localhost:8082/test.aspx. 51 | 52 | Example (Owin) 53 | ============== 54 | 55 | sharpfastcgi now has an Owin-compatible ChannelFactory that allows you to run any 56 | Owin-compatible middleware as a FastCGI application. It has been tested with Microsoft 57 | WebAPI 5.2.3 and with the various Microsoft security middlewares for authentication to 58 | ADFS, Facebook, Twitter, etc. 59 | 60 | A minimal example for IIS would look like this: 61 | 62 | ```c# 63 | static class Program 64 | { 65 | static int Main(string[] args) 66 | { 67 | var logger = LoggerFactory.Create("Owin Test"); 68 | logger.Log(LogLevel.Info, "Starting fastcgi server"); 69 | 70 | var server = CreateServer(); 71 | server.Start(); 72 | 73 | while (true) 74 | { 75 | Thread.Sleep(1000); 76 | } 77 | } 78 | 79 | private static IFastCgiServer CreateServer() 80 | { 81 | return new IisServer(new OwinChannelFactory(LoggerFactory, applicationRegistration), LoggerFactory); 82 | } 83 | 84 | private static ILoggerFactory _loggerFactory; 85 | 86 | private static ILoggerFactory LoggerFactory 87 | { 88 | get 89 | { 90 | if (_loggerFactory != null) 91 | return _loggerFactory; 92 | 93 | return _loggerFactory = new Grillisoft.FastCgi.Loggers.Log4Net.LoggerFactory(); 94 | } 95 | } 96 | 97 | static void applicationRegistration(IAppBuilder app) 98 | { 99 | // Register your Owin middlewares here 100 | // This example uses ADFS Bearer Auth and WebAPI 101 | 102 | var configuration = new HttpConfiguration(); 103 | 104 | app.UseActiveDirectoryFederationServicesBearerAuthentication( 105 | new ActiveDirectoryFederationServicesBearerAuthenticationOptions 106 | { 107 | MetadataEndpoint ="MyMetadataEndpoint", 108 | TokenValidationParameters = new TokenValidationParameters() 109 | { 110 | ValidAudience = "MyAudience" 111 | } 112 | }); 113 | 114 | app.UseWebApi(configuration); 115 | } 116 | } 117 | ``` 118 | 119 | Documentation 120 | ============ 121 | You can also read this article I wrote about this library so you can have a deeper understanding on how it works: http://www.codeproject.com/Articles/388040/FastCGI-NET-and-ASP-NET-self-hosting 122 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.0.{build} 2 | 3 | # branches to build 4 | branches: 5 | # blacklist 6 | except: 7 | - gh-pages 8 | 9 | # build cache to preserve files/folders between builds 10 | cache: 11 | - packages 12 | 13 | # enable patching of AssemblyInfo.* files 14 | assembly_info: 15 | patch: true 16 | file: AssemblyInfo.* 17 | assembly_version: "{version}" 18 | assembly_file_version: "{version}" 19 | assembly_informational_version: "{version}" 20 | 21 | # build platform, i.e. x86, x64, Any CPU. This setting is optional. 22 | platform: Any CPU 23 | 24 | # build Configuration, i.e. Debug, Release, etc. 25 | configuration: Release 26 | 27 | before_build: 28 | - nuget restore 29 | 30 | build: 31 | parallel: true # enable MSBuild parallel builds 32 | project: FastCgi.sln # path to Visual Studio solution or project 33 | publish_nuget: true # package projects with .nuspec files and push to artifacts 34 | publish_nuget_symbols: false # generate and publish NuGet symbol packages 35 | 36 | test: 37 | 38 | # here we are going to override common configuration 39 | for: 40 | 41 | # override settings for `stable` branch 42 | - 43 | branches: 44 | only: 45 | - stable 46 | 47 | configuration: Release 48 | 49 | deploy: 50 | provider: NuGet 51 | api_key: 52 | secure: t5VmoPZFy/8eIv4i5yyLuHQ9cVvrGTsAgV4olTuWi5RPiu2UOb1LAgA0aTQMNnEq 53 | skip_symbols: false 54 | symbol_server: # remove to push symbols to SymbolSource.org 55 | artifact: /.*\.nupkg/ 56 | -------------------------------------------------------------------------------- /stress_test.bat: -------------------------------------------------------------------------------- 1 | "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\ab" -n 100 -c 16 http://localhost:81/test.aspx 2 | pause --------------------------------------------------------------------------------