swirl
Guide to OmniMark 8   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax     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 Syntax
   HttpObjectSetHeader
   HttpObjectSetCookieAttribute
   HttpObjectSetCookieValue
 
  Other Library Functions
   HttpConnectionSendResponse
   HttpLibraryVersion
   HttpObjectGetCookieAttributes
   HttpObjectGetCookieValues
   HttpObjectGetHeaders
   HttpObjectGetStatusReport
   HttpObjectIsInError
   HttpObjectSetCookieAttribute
   HttpObjectSetCookieValue
   HttpObjectSetHeader
   HttpRequest
   HttpRequestGetSearchItems
   HttpRequestSend
   HttpRequestSetFromUrl
   HttpRequestSetProxy
   HttpRequestSetSearchItem
   HttpResponse
   HttpResponseOutput
   HttpServiceAwaitRequest
 
 

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

OmniMark 8.2.0 Documentation Generated: March 13, 2008 at 3:27:39 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.