swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Topics   Other Library Functions  
function  

HttpConnectionSendResponse

 
 

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

Declaration

define function HttpConnectionSendResponse
               value   TCPConnection Connection
               send   modifiable stream Response
    timeout     value       integer        Timeout optional initial {10000}

Argument definitions

Connection
is a TCP connection object that is the connection between the server and client (input argument).
Response
is the HTTP response object containing data to send to the client (input argument).
Timeout
is the maximum number of milliseconds to wait for a communication operation before failing (input argument).


Purpose

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.

Requirements

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

  include "omhttp.xin"

Usage Notes

Connection is set to an error state if the TCP communication times out.

Example

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.")

    Related Topics
 
Other Library Functions
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:38:10 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.