This is the not-so-amazing but very simple Gossamer web service. There isn't very much going on here, but as you can see it is fairly easy to embed a simple HTTP server within a VB6 application.
Some of the features of Gossamer include:
Static content is served from a predefined single VDir directory. Dynamic content is handled by raising an event back to the parent application for processing. Activity logging is handled through another event.
Just drop a Gossamer control onto your main VB Form, set a few properties, wire up the events, call StartListening, and you're on your way. You may not even need those events!
DefaultPage - Page fetched when directory requests are made (design-time default: "index.htm").
MaxConnections - Maximum number of open client connections, beyond which more will be refused (design-time default: 32).
Port - TCP port to listen on for HTTP client connections (design-time default: 8080). Can be overridden by passing a value to StartListening.
VDir - Directory containing your static content (design-time default: ""). This can be an absolute path or relative path, which will be relative to your application's current directory. Can't be changed while listening for client connections.
VDirPath - Read-only value returning the fully qualified path to the current VDir setting.
ExtensionToMIME - Converts a file extension (without the ".") to the corresponding content MIME type string. You can easily expand this beyond the basic extentions already included.
GetFreeFile - VB6 FreeFile() call that tries for the lower 255 file slots first and moves to the exclusive access slots if these are exhausted. Helpful when a server is busy and may have many files open. Fails if no file numbers are available at all.
StartListening - Optionally specify a Port and IP address of the adapter to bind to, to start the HTTP service.
StopListening - Halt the HTTP service.
URLDecode - Converts HTTP URI parameter text from URL-encoded to plaintext.
UTCDateTime - Converts local timezone VB6 Date type values from local time to UTC Date values.
UTCParseString - Converts HTTP-compliant timestamp strings to Date values, if not valid returns Now() in UTC time.
UTCString - Converts local timezone VB6 Date type values to UTC time strings in HTTP-compliant format for headers.
DynamicRequest - Passes a set of arguments describing the request including the request method, headers, URI, request parameters, and request content if any.
LogEvent - Passes a GossEvent object detailing the event to be examined and/or logged.
Remember that in the simplest case you do not need to handle the events. Just set the properties and start the service.
Dynamic page example with HTML GET Form Submit for use with GossDemo1.
Dynamic page example with HTML POST Form Submit for use with GossDemo1.