Message (HttpResponse function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Template:HttpResponse:Message subtitle}}
{{Template:HttpResponse:Message subtitle}}
The <var>Message</var> non-settable method lets you examine the HTTP status line (return code and message) of the result of the most recent HTTP request.  <var>Message</var> returns only the message portion of the status line (for example, <code>Forbidden</code> is returned from a <code>403</code> <code>Forbidden</code> status line).


This non-settable method lets you check the HTTP
status line (return code and message) of the
result of the most recent HTTP request.
The Message method returns only the message portion of the status line
(for example, <code>Forbidden</code> is returned from
a <code>403</code> <code>Forbidden</code> status line).
==Syntax==
==Syntax==
{{Template:HttpResponse:Message syntax}}
{{Template:HttpResponse:Message syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%message</th>
<tr><th>%string</th>
<td>A string or longstring variable for the assignment of the Message value of ''%httpresp''.
<td>A string or longstring variable for the assignment of the <var>Message</var> value of <var class="term">httpResponse</var>.
</td></tr>
</td></tr>
<tr><th>%httpresp</th>
<tr><th>httpResponse</th>
<td>A reference to an HTTPResponse object that was returned by a Get, Post, or Send method of an HTTPRequest object.
<td>A reference to an <var>[[HttpResponse_class|HttpResponse]]</var> object that was returned by a <var>[[Get_(HttpRequest_function)|Get]]</var>, <var>[[Post_(HttpRequest_function)|Post]]</var>, or <var>[[Send_(HttpRequest_function)|Send]]</var> method of an <var>[[HttpRequest_class|HttpRequest]]</var> object.</td></tr>
</table>


</td></tr></table>
==Examples==
==Examples==
 
In the following fragment, an XML document is being retrieved. In the event of an error, the text of the status message is printed:
In the following fragment, an XML document is being retrieved.
In the event of an error, the text of the status message is printed:
<p class="code">  . . .
<p class="code">  . . .
   %httpresp = %httpreq:Get('HHELPCLI', 0)
   %httpresp = %httpreq:get('HHELPCLI', 0)
     If (%httpresp:Success) then
     if (%httpresp:[[Success_(HttpResponse_function)|success]]) then
       %rc = %httpresp:ParseXML(%mydoc)
       %rc = %httpresp:[[ParseXml_(HttpResponse_function)|parseXML]](%mydoc)
       %mydoc:Print
       %mydoc:[[Print_(XmlDoc/XmlNode_subroutine)|print]]
     Else
     else
     Print %httpresp:message
     print %httpresp:message
     End If
     end if
   . . .
   . . .
</p>
</p>
==See also==
==See also==
{{Template:HttpResponse:Message footer}}
{{Template:HttpResponse:Message footer}}

Latest revision as of 19:39, 20 June 2011

Return code message of most recent request (HttpResponse class)

The Message non-settable method lets you examine the HTTP status line (return code and message) of the result of the most recent HTTP request. Message returns only the message portion of the status line (for example, Forbidden is returned from a 403 Forbidden status line).

Syntax

%string = httpResponse:Message

Syntax terms

%string A string or longstring variable for the assignment of the Message value of httpResponse.
httpResponse A reference to an HttpResponse object that was returned by a Get, Post, or Send method of an HttpRequest object.

Examples

In the following fragment, an XML document is being retrieved. In the event of an error, the text of the status message is printed:

. . . %httpresp = %httpreq:get('HHELPCLI', 0) if (%httpresp:success) then %rc = %httpresp:parseXML(%mydoc) %mydoc:print else print %httpresp:message end if . . .

See also