HttpResponseOutput

function

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

Declaration
define function HttpResponseOutput
     modifiable stream Response

Argument definitions

Response
is the HTTP response to be sent.


Purpose

Use HttpResponseOutput to format the contents of a response object as a valid HTTP-formatted message and write it to the current output.

Requirements

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

  include "omhttp.xin"

Usage Notes

This function is generally located in a server program and is used by the HttpConnectionSendResponse function.

Example


  include "omtcp.xin"
  include "omhttpsv.xin"
  
  define function ReturnHttpResponse
     (value       TCPConnection  connection,
      read-only   stream         response-body)
  as
     ; local variables
     local HttpResponse response
     local stream       write-to-client
  
     ; set the message body
     open response{'entity-body'} as buffer
     using output as response{'entity-body'}
     do
        output '<html><head><title>HttpResponseOutput Example</title></head><body>'
        output response-body
        output '</body></html>'
     done
     close response{'entity-body'}
  
     ; send response over the provided TCP connection
     open write-to-client as TCPConnectionGetOutput connection timeout 10000
     using output as write-to-client
       HttpResponseOutput Response
     close write-to-client