Web server version - 134 CHAPTER 5 PERMUTATIONS PATTERN if (_text.IsMatch(mimetype))

134 CHAPTER 5 PERMUTATIONS PATTERN if (_text.IsMatch(mimetype)) { return DoesFileExistAndRewrite(”default.txt”); } if (String.Compare(mimetype, “*/*”) == 0) { return DoesFileExistAndRewrite(”content.html”); } return false; The implementation of the method WriteRedirection will iterate a series of if statements to test which MIME type has been passed in. If any one particular MIME type matches the type, the method DoesFileExistAndRewrite is called. The method DoesFileExistAndRewrite will test whether the proposed rewritten URL references a file that exists, and if so the URL is rewritten. The big idea of the operation for the URL rewriter is to generate a potential URL and test whether there is a file available on the storage medium. If the file exists, the URL can be rewritten; otherwise, another MIME type is tested for availability. If a representation exists, WriteRedirection will return true and consider the URL rewritten, which causes an exit, thus implementing the last step, step 6. The defined DefaultRewriter will work for static content, but not for dynamic content such as PHP, JSP, or even ASP.NET because the redirections always reference static extensions such as XML, HTML, and XHTML. Suppose PHP is used for generating XML and HTML content. If a request (for example, /content) requires generation of XML content, the generated filename E B V N will end with .php (for example, /content.php). Yet if the request requires dynamic generation of HTML, the generated filename will end with .php again (for example, /content.php). One solution would be to append the dynamic script extension and type (for example, HTML would be /content.html.php). The appending of two extensions is used by Apache when sending language-specific content. Generating the Content When the rewriting component executes its code, the rewriting of the URL /bankaccount/login to the URL /bankaccount/login.jsp occurs transparently. The next step is to test whether the URL is indeed rewritten, so let s watch Firefox s decision process as it calls the URL. Figure 5-10 illustrates how the browser loads the appropriate document, and that the server tests what the appropriate document would be. The bottom window of Figure 5-10 is a Secure Shell (SSH) console window of the Mono XSP ASP.NET server running on Linux. The asterisks represent the beginning and ending of an HTTP request. The first line, which starts with Path, is the absolute path of the ASP.NET appli cation s physical path appended with the URL. The next line, which reads Is routable, indicates that a resource has been requested. Then the HTTP Accept header sent by Mozilla is reorga nized and then tested to see whether the content can be downloaded. Notice how the various MIME types are iterated and tested. The last MIME type tested is text/html, because the path associated with the MIME type exists. There are other MIME types, but they are not iterated because a MIME type has been found.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Leave a Reply