![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Node.js) HTTP Response InspectionSee more HTTP ExamplesDemonstrates how to inspect the HTTP response, including the status code, status text, and response headers, for Chilkat methods that don't use anHttpResponse object.
var os = require('os'); if (os.platform() == 'win32') { var chilkat = require('@chilkat/ck-node23-win64'); } else if (os.platform() == 'linux') { if (os.arch() == 'arm') { var chilkat = require('@chilkat/ck-node23-linux-arm'); } else if (os.arch() == 'arm64') { var chilkat = require('@chilkat/ck-node23-linux-arm64'); } else { var chilkat = require('@chilkat/ck-node23-linux-x64'); } } else if (os.platform() == 'darwin') { var chilkat = require('@chilkat/ck-node23-mac-universal'); } function chilkatExample() { var http = new chilkat.Http(); // Returns the contents of the response body. var jsonText = http.QuickGetStr("https://chilkatsoft.com/helloWorld.json"); // Examine the response status code. console.log("response status code: " + http.LastStatus); // Examine the response status text console.log("response status text: " + http.LastStatusText); // Examine the full response header. console.log("response header:"); console.log(http.LastResponseHeader); console.log("----"); // Examine the response content-type console.log("LastContentType = " + http.LastContentType); // Examine the response last-mod date console.log("LastModDate = " + http.LastModDate); // Load the response header into a Chilkat MIME object to access its fields individually. var mime = new chilkat.Mime(); mime.LoadMime(http.LastResponseHeader); var numHeaders = mime.NumHeaderFields; var i = 0; console.log("---- MIME Headers ----"); while (i < numHeaders) { console.log("name: " + mime.GetHeaderFieldName(i)); console.log("value: " + mime.GetHeaderFieldValue(i)); i = i+1; } console.log("----"); // Get a header field value by name: console.log("ETag: " + mime.GetHeaderField("ETag")); // Output: // response status code: 200 // response status text: OK // response header: // Content-Type: application/json // Last-Modified: Sun, 20 Aug 2023 11:36:27 GMT // Accept-Ranges: bytes // ETag: "34c27f8e5ad3d91:0" // Server: Microsoft-IIS/10.0 // X-Powered-By: ASP.NET // Date: Sat, 30 Aug 2025 14:38:13 GMT // Content-Length: 22 // ---- // LastContentType = application/json // LastModDate = 2023-08-20 // ---- MIME Headers ---- // name: Content-Type // value: application/json // name: Last-Modified // value: Sun, 20 Aug 2023 11:36:27 GMT // name: Accept-Ranges // value: bytes // name: ETag // value: "34c27f8e5ad3d91:0" // name: Server // value: Microsoft-IIS/10.0 // name: X-Powered-By // value: ASP.NET // name: Date // value: Sat, 30 Aug 2025 14:38:13 GMT // name: Content-Length // value: 22 // ---- // ETag: "34c27f8e5ad3d91:0" } chilkatExample(); |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.