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 7605379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:09:11+00:00 2026-05-31T00:09:11+00:00

To optimize my Perl application I need to work with async HTTP requests, so

  • 0

To optimize my Perl application I need to work with async HTTP requests, so I can handle other operations once the HTTP response is finish. So I believe my only option is to work with HTTP::Async module. This works fine for simple requests, but I need to catch cookie header from one response and send it with next one, so I need to read headers. My code is:

             ...

             $async->add($request);
             while ($response = $async->wait_for_next_response)
             {
               threads->yield(); yield();
             }
             $cookie = $response->header('Set-Cookie');
             $cookie =~ s/;.*$//;
             $request->header('Cookie' => $cookie);

             ...

but it’s not working, as it ends with an error Can’t call method “header” on an undefined value. Obviously $response is undef. How can I catch headers before $response gets undef?

  • 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-05-31T00:09:12+00:00Added an answer on May 31, 2026 at 12:09 am
    while ($response = $async->wait_for_next_response)
    {
      threads->yield(); yield();
    }
    

    Is guaranteed not to finish until $response is false. The only false value wait_for_next_response will return is undef. You need to either extract the cookie inside the loop, or cache the last good response inside the loop.

    Something like

    my $last_response;
    while ($response = $async->wait_for_next_response)
    {
      $last_response = $response;
      threads->yield(); yield();
    }
    

    should work, although I’m not sure you need the loop at all. It’s hard to tell without a complete program.

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

Sidebar

Related Questions

We need to optimize the text rendering for a C# Windows Forms application displaying
I need to optimize code to get room for some new code. I do
Or: Should I optimize my string-operations in PHP? I tried to ask PHP's manual
Will the Java Compiler optimize simple repeated math operations like: if (prevX / width
I'm trying to optimize response time on a page with a large table that
I'm looking for a performance comparison between perl and boost regular expression. I need
After I REPAIR OPTIMIZE ANALYZE OR CHECK a table, do I need to FLUSH
I am trying to optimize the code for an application we are currently developping.
The PSGI specification defines the HTTP response as consisting of three parts, the third
Other than the purely obvious: It translates Perl to C.; are there any real

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.