| 
||||||||||
| 
 | 
||||||||||
| Related Syntax | Other Library Functions | |||||||||
| function | HttpConnectionSendResponse | 
  Available in:
   Enterprise Professional  | 
| 
Library: omhttp - HTTP support
 Include: omhttp.xin  | 
  define function HttpConnectionSendResponse
                 value   TCPConnection Connection
                 send   modifiable stream Response
      timeout     value       integer        Timeout optional initial {10000}
where
Use HttpConnectionSendResponse to construct an HTTP message from an HTTP response object and return it to the client from the server over the specified connection.
You must include the following line at the beginning of your OmniMark program: 
include "omhttp.xin"
Connection is set to an error state if the TCP communication times out.
To run this example, you must run the program and then start a web browser or client. In the browser, enter
http://your-machine-name:5279
after substituting the name of your machine in place of your-machine-name.
You will then see the response displayed in your browser.
  include "omtcp.xin"
  include "omhttp.xin"
  define function ReturnHttpResponse
     (value       TCPConnection  connection,
      value   stream         response-body)
  as
     ; local variables
     local HttpResponse response
     ; set the message body
     open response{'entity-body'} as buffer
     using output as response{'entity-body'}
     do
        output '<html><head><title>HttpConnectionSendResponse Example</title></head><body>'
        output '<body><h1>Here is the response</h1>'
        output response-body
        output '</body></html>'
     done
     close response
     ; send response over the provided TCP connection
     HttpConnectionSendResponse connection send response timeout 45000
  process
     local stream my-response
     local TCPService my-Service
     local TCPConnection client-Connection
     local HttpRequest new-Request
     set my-Service to TCPServiceOpen at 5279
     HttpServiceAwaitRequest my-Service receive new-Request connection client-Connection timeout 30000
     ReturnHttpResponse(client-Connection, "This text will appear in your browser.")     
| ---- |