home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / ASP / http.asp < prev    next >
Encoding:
Text File  |  2001-06-08  |  2.8 KB  |  92 lines

  1. <%
  2. '*******************************************************
  3. '*     ASP 101 Sample Code - http://www.asp101.com     *
  4. '*                                                     *
  5. '*   This code is made available as a service to our   *
  6. '*      visitors and is provided strictly for the      *
  7. '*               purpose of illustration.              *
  8. '*                                                     *
  9. '* Please direct all inquiries to webmaster@asp101.com *
  10. '*******************************************************
  11. %>
  12.  
  13. <%
  14. ' Start out declaring our variables.
  15. ' You are using Option Explicit aren't you?
  16. Dim objXmlHttp
  17. Dim strHTML
  18.  
  19. ' This is the server safe version from MSXML3.
  20. Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
  21.  
  22. ' If you have trouble and are getting an error on the .open
  23. ' line like this:
  24. '
  25. ' msxml3.dll error '80070005'
  26. ' Access is denied.
  27. '
  28. ' Try using the proxycfg.exe tool.  We're not using a proxy
  29. ' at all, but it wouldn't work for us until we explicitly
  30. ' ran proxycfg telling it the connection is direct:
  31. ' proxycfg -d
  32. '
  33. ' forum posts: http://www.asp101.com/forum/display_message.asp?mid=51841
  34. '
  35. ' This had us really annoyed for a while!  Thanks go out to
  36. ' Andrew Stifora and Brian Espey for help on getting that
  37. ' straightened out.
  38.  
  39. ' The old not so safe version!
  40. 'Set objXmlHttp = Server.CreateObject("Msxml2.XMLHTTP")
  41.  
  42. ' Here we get the request ready to be sent.
  43. ' MS's wording: 'Initializes a request and specifies the method,
  44. ' URL, and authentication information for the request.
  45. ' Syntax:
  46. '   .open(bstrMethod, bstrUrl, bAsync, bstrUser, bstrPassword)
  47. 'objXmlHttp.open "GET", "http://www.asp101.com/samples/httpsamp.asp", False
  48. objXmlHttp.open "GET", "http://10.2.3.180/samples/httpsamp.asp", False
  49.  
  50. ' Send it on it's merry way.
  51. objXmlHttp.send
  52.  
  53. ' Print out the request status:
  54. Response.Write "Status: " & objXmlHttp.status & " " _
  55.     & objXmlHttp.statusText & "<br />"
  56.  
  57. ' Get the text of the response.
  58. ' This object is designed to deal with XML so it also has the
  59. ' following properties: responseBody, responseStream, and
  60. ' responseXML.  We just want the text so I use:
  61. strHTML = objXmlHttp.responseText
  62.  
  63. ' Trash our object now that I'm finished with it.
  64. Set objXmlHttp = Nothing
  65.  
  66. ' All that's left to do is display the HTML we just retreived.
  67. ' I do it first as plain HTML (which gets interpretted by the
  68. ' browser like any other HTML) and then as source (by HTML
  69. ' encoding it so the tags display instead of rendering)
  70. ' The <h1>s and <table>s are just for appearence.
  71. %>
  72.  
  73. <h1>Here's The Page:</h1>
  74. <table border="1" bgcolor="#FFFFFF">
  75. <tr><td>
  76. <%= strHTML %>
  77. </td></tr>
  78. </table>
  79.  
  80. <br />
  81.  
  82. <h1>Here's The Code:</h1>
  83. <table border="1" bgcolor="#FFFFFF">
  84. <tr><td>
  85. <pre>
  86.  
  87. <%= Server.HTMLEncode(strHTML) %>
  88. </pre>
  89. </td></tr>
  90. </table>
  91.