Message (HttpResponse function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
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}}
Line 14: Line 9:
<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 Message value of ''%httpresp''.
</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==
 
<ol><li>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></ol>
 
==See also==
==See also==
{{Template:HttpResponse:Message footer}}
{{Template:HttpResponse:Message footer}}

Revision as of 06:04, 19 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

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

Examples

  1. 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