OPTIONS HTTP Request in Perl

1.2k Views Asked by At

Need to send HTTP OPTIONS Request in Perl. Looked through several CPAN modules; read the docs, no mention of OPTIONS request method, just GET, POST, PUT, DELETE.

Do I need to format this manually? Or is there possibly another library/module that my google-fu is missing out on?

1

There are 1 best solutions below

0
On

The documentation for the HTTP::Request module says:

The method should be a short string like "GET", "HEAD", "PUT" or "POST".

So:

use v5.16;
use warnings;

use HTTP::Request;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new(OPTIONS => 'http://www.example.com/');
my $response = $ua->request($request);

I don't have a server that gives a useful response to an OPTIONS request to test the response with, but the request looks OK when I examine it after setting a proxy.