<div>$ pwd</div><div>/home/jschauma</div><div>$ sws -c ./sws/cgi-bin ./sws</div><div><br></div><div>HTTP request       absolute pathname</div><div>------------------------------------------------------------------------</div>
<div>/                   /home/jschauma/sws/index.html (or directory listing)</div><div>/cgi-bin/foo        /home/jschauma/sws/cgi-bin/foo</div><div><br></div><div>Above is a example you gave to us.</div><div><br></div><div>
For your information in response, The second request /cig-bin/foo is not the same as the path which is /sws/cgi-bin specified after -c flag.</div><div>So we treat the second request as a normal request even though it is under home/jschauma/sws/cgi-bin/ (the CGI directory)?</div>
<div><br></div><div>Thanks</div><div><br></div><div><div><br></div><div><div class="gmail_quote">2012/12/11 Jan Schaumann <span dir="ltr"><<a href="mailto:jschauma@stevens.edu" target="_blank">jschauma@stevens.edu</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">ccui1 <<a href="mailto:ccui1@stevens.edu">ccui1@stevens.edu</a>> wrote:<br>
<br>
> We run the server like ./sws -c ./usr/cgi_bin ./usr/htdocs<br>
> (1) Assume we both have ./usr/cgi_bin/foo and ./usr/htdocs/cgi_bin/foo<br>
> These are two different files with the same name.<br>
> One is under cgi_root, the other is under server root.<br>
><br>
> Now a quest like GET /cgi_bin/foo come to the server.<br>
> How can we handle this request? We process it as a cgi request or a<br>
> normal request?<br>
<br>
</div>The "-c" flag specified that content found by the name "./usr/cgi_bin"<br>
under the document root would be served as a CGI.  That is, if a request<br>
comes for:<br>
<br>
GET /usr/cgi_bin/foo HTTP/1.0<br>
<br>
...then you would serve it as a CGI.<br>
<br>
A request for<br>
<br>
GET /cgi_bin/foo HTTP/1.0<br>
<br>
would be served as a regular file, since "/cgi_bin/" is not the same as<br>
"/usr/cgi_bin".<br>
<div class="im"><br>
> If we run the server like ./sws -c ./usr/cgi/test ./usr/htdocs<br>
><br>
> Now the cgi root is ./usr/cgi/test.<br>
><br>
> What kind of request is regarded as a CGI request?<br>
<br>
</div>GET /usr/cgi/test/foo HTTP/1.0<br>
<br>
would be treated as a CGI.<br>
<div class="im"><br>
> Do we need to force that a request staring with a /cgi_bin/ is a CGI<br>
> request?<br>
<br>
</div>No.  Only requests starting with the string given to the '-c' flag<br>
relative to the document root are treated as CGIs.<br>
<br>
Now we _could_ also stipulate that *if* the '-c' flag specifies a<br>
directory outside of the document root, then any request for<br>
"/cgi-bin/foo" would be translated to that path.<br>
<br>
If you choose to implement this, then that's fine, too.<br>
<div class="im"><br>
> If the cgi root is ./usr/cgi/test/<br>
> The request is GET /cgi_bin/dir/subdir/file HTTP/1.0.<br>
> We finally regard the request as ./usr/cgi/test/dir/subdir/file.<br>
<br>
</div>No, that is not what the manual page says.<br>
<div class="im"><br>
> If this is the case, what if there are the same path and files under<br>
> both CGI root and the server root. Which one will be used?<br>
<br>
</div>A request matching a CGI path will take precedence.<br>
<div class="im"><br>
> (2)Will the -l and -d options override each other?<br>
> If both of these two flags are given, which one will effect the server?<br>
<br>
</div>The two are independent.  "-d" enables logging of all system events to<br>
stdout.  That is, wherever you've used syslog(3) to log events<br>
previously, you now log those messages to stdout.  This does not<br>
constitute request logging, which is what '-l' enables.<br>
<br>
The reason for this is that the debugging mode is supposed to be useful:<br>
you want to see debugging information while running the server in the<br>
foreground, but you do not need to see all requests being logged (on a<br>
normal web server, that would be hundreds per second) -- those should go<br>
to a file and are logged without syslog(3).<br>
<span class="HOEnZb"><font color="#888888"><br>
-Jan<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
cs631apue mailing list<br>
<a href="mailto:cs631apue@lists.stevens.edu">cs631apue@lists.stevens.edu</a><br>
<a href="https://lists.stevens.edu/cgi-bin/mailman/listinfo/cs631apue" target="_blank">https://lists.stevens.edu/cgi-bin/mailman/listinfo/cs631apue</a><br>
</div></div></blockquote></div><br></div></div>