Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) Explaining the Rest ClearResponseBodyStream MethodSee more Azure Cloud Storage ExamplesThe ClearResponseBodyStream method would be needed if your applicaiton called SetResponseBodyStream to send the response to a stream for one request, but then wants to subsequently do something else. The application must call ClearResponseBodyStream to no longer send responses to the stream.
LOCAL loRest LOCAL lnBTls LOCAL lnPort LOCAL lnBAutoReconnect LOCAL lnSuccess LOCAL loFileStream LOCAL lnExpectedStatus LOCAL lcResponseStr LOCAL loBd * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Rest') loRest = CreateObject('Chilkat.Rest') * Connect to the web server lnBTls = 1 lnPort = 443 lnBAutoReconnect = 1 lnSuccess = loRest.Connect("www.chilkatsoft.com",lnPort,lnBTls,lnBAutoReconnect) IF (lnSuccess <> 1) THEN ? loRest.LastErrorText RELEASE loRest CANCEL ENDIF * Setup a file stream for the download * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Stream') loFileStream = CreateObject('Chilkat.Stream') loFileStream.SinkFile = "qa_output/starfish.jpg" * Indicate that the call to FullRequestNoBody should send the response body * to fileStream if the response status code is 200. * If a non-success response status code is received, then nothing * is streamed to the output file and the error response is returned by FullRequestNoBody. lnExpectedStatus = 200 loRest.SetResponseBodyStream(lnExpectedStatus,1,loFileStream) lcResponseStr = loRest.FullRequestNoBody("GET","/images/starfish.jpg") IF (loRest.LastMethodSuccess = 0) THEN * Examine the request/response to see what happened. ? "response status code = " + STR(loRest.ResponseStatusCode) ? "response status text = " + loRest.ResponseStatusText ? "response header: " + loRest.ResponseHeader ? "response body (if any): " + lcResponseStr ? "---" ? "LastRequestStartLine: " + loRest.LastRequestStartLine ? "LastRequestHeader: " + loRest.LastRequestHeader RELEASE loRest RELEASE loFileStream CANCEL ENDIF ? "downloaded starfish.jpg" * Clear the response body stream previously set in the call to SetResponseBodyStream. loRest.ClearResponseBodyStream() * Download something else, but this time send the response body to bd. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.BinData') loBd = CreateObject('Chilkat.BinData') lnSuccess = loRest.FullRequestNoBodyBd("GET","/images/penguins.jpg",loBd) IF (lnSuccess = 0) THEN * Examine the request/response to see what happened. ? "response status code = " + STR(loRest.ResponseStatusCode) ? "response status text = " + loRest.ResponseStatusText ? "response header: " + loRest.ResponseHeader ? "response body (if any): " + loBd.GetString("utf-8") ? "---" ? "LastRequestStartLine: " + loRest.LastRequestStartLine ? "LastRequestHeader: " + loRest.LastRequestHeader RELEASE loRest RELEASE loFileStream RELEASE loBd CANCEL ENDIF * Save the contents of bd to a file. lnSuccess = loBd.WriteFile("qa_output/penguins.jpg") ? "Success: " + STR(lnSuccess) RELEASE loRest RELEASE loFileStream RELEASE loBd |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.