Message (HttpResponse function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
mNo edit summary |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{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). | |||
==Syntax== | ==Syntax== | ||
{{Template:HttpResponse:Message syntax}} | |||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>% | <tr><th>%string</th> | ||
<td>A string or longstring variable for the assignment of the Message value of | <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> | <tr><th>httpResponse</th> | ||
<td>A reference to an | <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> | |||
==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: | %httpresp = %httpreq:get('HHELPCLI', 0) | ||
if (%httpresp:[[Success_(HttpResponse_function)|success]]) then | |||
%rc = %httpresp: | %rc = %httpresp:[[ParseXml_(HttpResponse_function)|parseXML]](%mydoc) | ||
%mydoc: | %mydoc:[[Print_(XmlDoc/XmlNode_subroutine)|print]] | ||
else | |||
print %httpresp:message | |||
end if | |||
. . . | . . . | ||
</p> | </p> | ||
==See also== | |||
{{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 . . .