The Neokernel web server services http requests. If an incoming request is for a static file like an HTML file, the web server delivers it. If the request URI ends in .agent, the web server uses a custom C# or Visual Basic object to generate the response. Objects that generate responses in this way implement the RequestAgent interface. If the server can't find a file or a RequestAgent to match the client's request, a 404 (file not found) error is returned. Typically, an HTTPFileServerAgent is used to serve static files like images or HTML. The HTTPFileServerAgent also handles ASP.NET pages if the file ends with the .aspx extension.
Custom RequestAgents are commonly used in conjunction with the WebServer and SecureWebServer classes to handle HTTP requests dynamically. Here's an example of a simple RequestAgent written in Visual Basic:
Imports com.neokernel.nk
Imports com.neokernel.util
Public Class SimpleVBPage
Inherits RequestAgent
Overrides Sub handleRequest(ByVal Request As AgentRequest)
Dim title, body As String
body = getString("body")
Request.println(body)
End Sub
Overrides Sub initProps()
setDefault("service_name", "/simple.agent")
setDefault("body", "This is output from the SimplePage agent!")
End Sub
End Class
If a browser requests http://localhost/simple.agent from a server that has started the above SimpleAgent, the browser will display the text
This is output from the SimplePage agent!
Here is the exact same agent written using C#:
using System;
using com.neokernel.nk;
public class SimplePage : RequestAgent
{
public override void initProps()
{
setDefault("service_name", "/simple.agent");
setDefault("body", "This is output from the SimplePage agent!");
}
public override void handleRequest(HTTPAgentRequest request)
{
String body = getString("body");
request.println( body );
}
}
WebServer supports the following Props entries:
true
HTTPRedirectAgent to redirect incoming requests. This prop is not set to a default value. HTTPProxyAgent to proxy incoming requests. This prop is not set to a default value. HTTPAuthenticationAgent to demand passwords for certain URLs specified in the http.authentication file. This prop is not set to a default value. For a list of all members of this type, see WebServer Members .
System.Object
Props
Agent
WebServer
SecureWebServer
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
Namespace: com.neokernel.httpd
Assembly: Neokernel (in Neokernel.exe)
WebServer Members | com.neokernel.httpd Namespace