Sample code for 30+ languages & platforms
Perl

Inspect HTTP Request Header

Demonstrates the LastHeader property.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

my $http = Chilkat2::Http->new;

my $url = 'https://chilkatsoft.com/echo_request_body.asp';
my $json = '{"greeting":"Hello World"}';

# Send a POST with the JSON in the HTTP request body.
my $resp = Chilkat2::HttpResponse->new;
my $success = $http->HttpStr('POST', $url, $json, 'utf-8', 'application/json', $resp);
if (!$success) {
    print $http->LastErrorText, "\n";
    exit;
}

# Examine the HTTP request header we just sent.
print $http->LastHeader, "\n";

# Output:

# POST /echo_request_body.asp HTTP/1.1
# Host: chilkatsoft.com
# Accept: */*
# Accept-Encoding: gzip
# Content-Type: application/json
# Content-Length: 26