Difference between revisions of "Content (HttpResponse function)"

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 1: Line 1:
 
+
{{Template:HttpResponse:Content subtitle}}
<span class="pageSubtitle"><section begin=dpl_desc/><section end=dpl_desc/></span>
 
[[Category:HttpResponse methods|Content function]]
 
<p>
 
<var>Content</var> is a member of the <var>[[HttpResponse class|HttpResponse]]</var> class.
 
</p>
 
  
 
This method lets you access the document/content from Get, Post, and Send
 
This method lets you access the document/content from Get, Post, and Send
Line 12: Line 7:
 
option of ASCII-to-EBCDIC translation.
 
option of ASCII-to-EBCDIC translation.
 
==Syntax==
 
==Syntax==
<p class="syntax">%longstring = %httpsresp:Content[(binflag)]
+
{{Template:HttpResponse:Content syntax}}
</p>
 
 
 
 
===Syntax terms===
 
===Syntax terms===
 
<table class="syntaxTable">
 
<table class="syntaxTable">
Line 27: Line 20:
  
 
</td></tr></table>
 
</td></tr></table>
==Usage Notes==
+
==Usage notes==
 
<ul>
 
<ul>
 
<li>Invoke <var>Content</var> only
 
<li>Invoke <var>Content</var> only
Line 56: Line 49:
 
   ...
 
   ...
 
</p>
 
</p>
==See Also==
+
==See also==
 +
{{Template:HttpResponse:Content footer}}
 
<ul>
 
<ul>
 
<li>For information about returning response contents into a <var>Stringlist</var>,
 
<li>For information about returning response contents into a <var>Stringlist</var>,
 
see the <var>[[ContentToStringlist (HttpResponse function)|ContentToStringlist]]</var> method.
 
see the <var>[[ContentToStringlist (HttpResponse function)|ContentToStringlist]]</var> method.
 
</ul>
 
</ul>

Revision as of 19:41, 17 June 2011

Get raw HTTP response data (HttpResponse class)


This method lets you access the document/content from Get, Post, and Send operations. Content returns the entire document into a longstring with no parsing: you get the raw bytes as they were returned from the HTTP request, with the option of ASCII-to-EBCDIC translation.

Syntax

%string = httpResponse:Content[( [number])]

Syntax terms

%longstring A longstring variable.
%httpresp A reference to an HTTPResponse object that was returned by a Get, Post, or Send method of an HTTPRequest object.
binflag A numeric expression that, if nonzero, indicates binary data. Setting this option overrides the default behaviour, which is to translate ASCII data to EBCDIC.

Usage notes

  • Invoke Content only if a successful HTTP transaction has occurred, that is, if the Success property value is True. If Content is called after an unsuccessful operation, the request is cancelled.
  • If the content type header indicates HTML, XML, or plain text, ASCII-to-EBCDIC translation is performed. If the Clsock port definition specifies a translation table for ASCII-to-EBCDIC, that table is used instead of the default.

Example

In the following fragment, an HTTPResponse object receives a .PDF file from a remote URL into a Longstring, leaving the data in binary format:

%httpreq is object httpRequest %httpresp is object httpResponse %pdf is longstring %url is longstring ... %httpreq = new %httpreq:url = %url %httpresp = %httpreq:get If (%httpresp:Success) then %pdf = %httpresp:content(1) ...

See also

  • For information about returning response contents into a Stringlist, see the ContentToStringlist method.