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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:49:42+00:00 2026-05-25T12:49:42+00:00

In groovy, is there a way to send a request to a URL, ignoring

  • 0

In groovy, is there a way to send a request to a URL, ignoring the response? The main aim is to send more requests to the server, in a shorter period of time.

As the result is unimportant to me, once the request is sent, I don’t want the script to wait for a response before continuing.

Here’s my current script:

(1..50).each { element->
  def url = "http://someUrl"
  url.toURL().text 
} 

In this code, the text method has to load the entire response, which I don’t really care about. The important part is that the request is sent, and waiting for a response is unimportant.

Is there a similar send method? (along the lines of..

url.toURL().send

Alternatively, is there a “groovy” way I can speed this up using GPARS to run the loop in parallel?

  • 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-25T12:49:42+00:00Added an answer on May 25, 2026 at 12:49 pm

    For just sending the URL, you could just use the withInputStream or withReader methods to send the request without reading the text. This will just create a handler to read the incoming text that would immediately close.

    As for GPars, you can just use a combination of withPool and callAysnc to create a thread pool to execute the requests concurrently. For example:

    @Grab(group='org.codehaus.gpars', module='gpars', version='0.12')
    import static groovyx.gpars.GParsExecutorsPool.withPool
    
    withPool(50) {
        50.times {
            Closure callUrl = {"http://google.com".toURL().withReader {}}
            callUrl.callAsync();
        }
    }
    

    However, if you’re not concerned with the number of threads, you could just create your own threads without GPars. For example:

    50.times { 
        Closure callUrl = {"http://google.com".toURL().withReader {}}
        Thread.start callUrl
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to access Gradle groovy plugin sourceSets dirs from my Groovy
Is there a way to control groovy's MarkupBuilder's output and filter out the newline
is there a way to 'break' out of a groovy closure. maybe something like
Is there a way to modify the code from a previous answer import groovy.xml.MarkupBuilder
Is there a way in Groovy to get the duration between two Date objects?
Is there a way to use anonymous code blocks in Groovy? For example, I'm
Is there a way to parse all all the classes in a groovy script?
Is there a way to use the groovy .collect method, but only up to
Is there a way in Groovy to find out the name of the called
Is there a way to make groovy ignore extra attributes in a map during

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.