HttpRequestSetProxy

function

Library: HTTP support (OMHTTP)
Include: omhttp.xin

Declaration
define function HttpRequestSetProxy
            modifiable  stream   Request
   host     value       string   Host
   port     value       integer  Port optional initial { 80 }

Argument definitions

Request
is an HTTP request object.
Host
is the URL of the proxy server
Port
is the port number on the proxy server to which you will be sending requests


Purpose

Use HttpRequestSetProxy to set the proxy server to be used for an HTTP request.

Requirements

You must include the following line at the beginning of your OmniMark program:


  include "omhttp.xin"

You must create an HTTP request with HttpRequestSetFromUrl

Usage Notes

After you use HttpRequestSetProxy, you can send a request with HttpRequestSend.

Example

The following program requests the OmniMark home page via a proxy server. You should set the appropriate values of proxy-server and proxy-port for the proxy server you are using.

  include "omhttp.xin"
  
  global HttpRequest Request
  global HttpResponse Response global stream proxy-server initial {"proxy.mycompany.com"}
  global integer proxy-port initial {80}
  
  process
  
      HttpRequestSetFromUrl Request from "www.omnimark.com:80"
      HttpRequestSetProxy Request host proxy-server port proxy-port
  
      HttpRequestSend Request into Response
      do unless HttpObjectIsInError Request
          output "%n<RESPONSE>%n"
          repeat over Response
              output key of Response
                  || " = "
                  || Response || "%n"
          again
      else
          local stream Report variable
          HttpObjectGetStatusReport Request into Report
          output "%n<REQUEST FAILED>%n"
          repeat over Report
              output Report || "%n"
          again
      done