Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8471547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:49:33+00:00 2026-06-10T16:49:33+00:00

I need to send requests that are formatted exactly as I specify, including whitespace.

  • 0

I need to send requests that are formatted exactly as I specify, including whitespace. What’s the best way to achieve this?

Example of the kind of request I want to send:

GET
/
key=val
Host:example.com

The protocol is a simple request-response protocol like HTTP. I’d prefer to take advantage of LWP’s existing code where possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:49:34+00:00Added an answer on June 10, 2026 at 4:49 pm

    I think it is be achievable with LWP. It’s a bit of work, to be honest.

    I’ve take a look at it, and you need to actually implement your own protocol (see LWP::Protocol) because that’s where the actual request is created. Afterwards, you will need to enable that protocol as implementor of http (or https):

    LWP::Protocol::implementor('http', 'MyFunkyProtocol');
    

    For an example, take a look at LWP::Protocol::GHTTP code.

    Simply saying, you need to create a package implementing a request method. In that method, you need to assemble the request, open the connection, send it and receive the response.


    Here’s a simple working example.

    MyFunkyProto.pm:

    package MyFunkyProto;
    
    use LWP::Protocol;
    @ISA = qw/LWP::Protocol/;
    
    use HTTP::Response;
    use IO::Socket;
    use Carp qw/croak/;
    
    sub request
    {
        my ($self, $request, $proxy, $arg, $size, $timeout) = @_;
    
        my $remote = IO::Socket::INET->new(
            Proto     => "tcp",
            PeerAddr  => "example.com",
            PeerPort  => "http(80)"
        ) or croak('unable to connect');
    
        my $message = <<EOF;
    GET
    /
    key=val
    Host:example.com
    EOF
    
        $remote->print($message);
        $remote->flush();
    
        local $/;
        my $resp = HTTP::Response->parse(<$remote>);
    
        $remote->close();
    
        return $resp;
    };
    
    1;
    

    script.pl:

    #!/usr/bin/env perl
    
    use strict;
    use warnings;
    use lib '.';
    
    use MyFunkyProto;
    use LWP::Protocol;
    use LWP::UserAgent;
    
    LWP::Protocol::implementor('http', 'MyFunkyProto');
    
    my $fr = HTTP::Request->new('GET', 'http://www.example.com/');
    my $ua = LWP::UserAgent->new();
    
    my $r = $ua->request($fr);
    print $r->as_string();
    

    Note that you will actually want to construct the request (and obtain the host and port) from the $request object. Or if you’re lazy, just store it somewhere in that object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm current working on some stuff that need to send cross-domain ajax requests. I'm
i'm writing some kind of application that will send http requests to server. My
I need to send SOAP requests to some web servicer as part of a
In my app, I need to send all sorts of POST requests to a
I need to send a big number of SIP requests to our server for
I need to send all requests for the directory home/alphauser to backend/alphauser, but not
I need to test an application that processes SIP requests. For now, I want
I need to consume a JSON-formatted data stream via WebSocket, and send the data
I need to send HTTP requests with all the standard RESTful methods and access
I am developing an api-like app that allows other applications to send requests which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.