home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD2001.psc / My Projects / HTTPServer / V2.0 / HTTPWebServer.cls < prev    next >
Encoding:
Visual Basic class definition  |  1999-04-29  |  1.3 KB  |  58 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "HTTPWebServer"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = False
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15.  
  16. Private WithEvents mServer As Server
  17. Attribute mServer.VB_VarHelpID = -1
  18.  
  19. Friend Function Initialize(srv As Server) As Boolean
  20.  
  21.   Set mServer = srv
  22.   
  23.   Initialize = Not (mServer Is Nothing)
  24.  
  25. End Function
  26.  
  27.  
  28. Private Sub Class_Terminate()
  29.  
  30.   Set mServer = Nothing
  31.  
  32. End Sub
  33.  
  34.  
  35. Private Sub mServer_OnRequest(Request As HTTPServiceRequest)
  36.  
  37.   Dim HeaderData As New DelimitedString
  38.   Dim ResponseData As String
  39.   
  40.   Const RESPONSE_DATA_TOP = "<html><body>Here's the page!<br>"
  41.   Const RESPONSE_DATA_END = "</body></html>"
  42.   
  43.   DebugPrint Request, Request.RawRequest
  44.   
  45.   ResponseData = RESPONSE_DATA_TOP & "You requested " & Request.URI & "<br><hr>" & RESPONSE_DATA_END
  46.   
  47.   With HeaderData
  48.     .Delimiter = vbNewLine
  49.     .Add "Content-type: text/html"
  50.     .Add "Content-length: " & Len(ResponseData)
  51.   End With
  52.   
  53.   Request.WriteResponse "200 OK", HeaderData, ResponseData
  54.  
  55. End Sub
  56.  
  57.  
  58.