Neokernel API

HTTPRedirectAgent Class

This Request Agent is used by the WebServer to determine whether a web request should be redirected and to actually redirect the request by returning the proper redirect code to the client.

If an HTTPRedirectAgent is running and the WebServer's redirect_agent prop is the same as the HTTPRedirectAgent's service_name, the agent will redirect requests for URLs in the http.redirect file. This file lists where to redirect to; URIs with multiple redirects listed in the file will be cycled between the listed redirects, providing a round-robin load distribution scheme.

The file format is name/value pairs delimited by newlines; lines starting with '#' are ignored. Complete URLs must be used to specify redirected URLs and the redirect targets. Here is an example of a redirect file:

http://myserver/redir1/file.htm=http://yahoo.com/
http://myserver/redir2/=http://redirect1:9000/
http://myserver/redir2/==http://redirect2:9000/
http://myserver/redir2/==http://redirect3:9000/
When a browser requests /redir1/file.html, it is redirected to http://yahoo.com. When it requests /redir2, it is redirected to http://redirect1:9000/. The next request for /redir2 is redirected to http://redirect2:9000/. The third incoming request is redirected to http://redirect3:9000/. The fourth request is redirected to http://redirect1:9000/, and the cycle is started again. In this way, the HTTPRedirectAgent can be used for round-robin style load balancing.

There are 2 kinds of name/value pairs used in the redirect configuration file. The first is a direct mapping in the format NAME=VALUE. This mapping tells the redirect agent to redirect PATH NAME to PATH VALUE.

A directly mapped NAME that contains a hostname must have a host in its VALUE. A direct mapping will not recurse subdirectories in a path and each path is regarded as literal. Directly mapped names can by mapped to multiple values if the values are separated by commas. The agent will cycle through each of the different paths given as the value.

The second kind of mapping maps only hosts to hosts, and passes the requested URL along with the redirected request for the mapped host to handle. This is an example of host-to-host mapping syntax:

http://myhost.com>http://www.myhost.com
No path information is included in the syntax of this mapping, only the host names. Any path intended for myhost.com will be mapped to the host www.myhost.com.

Note: Cyclical references in the redirect mappings are not checked, if the redirect file has cyclical references, clients can be put into an infinite loop of redirects.

service_name
The name this agent uses to register with Service Manager. The WebServer's proxy_agent prop must be set to match this agent's service_name, or requests for urls in the http.redirect file will not be handed off to this agent. The default value is http_redirect.agent.
redirect_file
The path to the file where redirect mappings are specified. Defaults to ./http.redirect
check_interval
Specifies the time to wait (in millisecs) between checking to see if the redirect target servers are up. Defaults to 300000
initial_wait_time
Specifies the time to wait after startup (in millisecs) before checking to see if the redirect target servers are up. Defaults to 600000
check_hosts
If set to true, the HTTPRedirectAgent will check every check_interval milliseconds to ensure that servers handling redirects are up. If one goes down, requests are not redirected to that server until it comes back online. Defaults to true
default_port
Specifies the port to redirect requests on. Defaults to 80

For a list of all members of this type, see HTTPRedirectAgent Members .

System.Object
   Props
      Agent
         ServiceAgent
            RequestAgent
               HTTPRedirectAgent

public class HTTPRedirectAgent : RequestAgent, IThreadRunnable

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Requirements

Namespace: com.neokernel.httpd

Assembly: Neokernel (in Neokernel.exe)

See Also

HTTPRedirectAgent Members | com.neokernel.httpd Namespace