Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3921

Add connection configuration options to URL.getText(), URL.newInputStream() and URL.newReader()

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.8.1
    • groovy-jdk
    • None
    • Patch

    Description

      There was a question on StackOverflow about how to set a timeout for URL.text

      http://stackoverflow.com/questions/1839435/setting-timeout-for-new-url-text-in-groovy-grails

      I have attached a patch which allows you to do:

      def s = new URL( 'http://www.google.com' ).getText( 10 )

      (which will give you a 10 millisecond timeout on both the connection and read – and return null if this timeout fires)

      No Tests Supplied

      I have no idea how you would test this in a non-contrived way, I have looked around for a URL.text test and it seems that I would need to mock the URL class, but I can't think how to do the timeout testing with this object

      Hope it's ok...

      Attachments

        1. URL.text-timout.patch
          3 kB
          Tim Yates

        Issue Links

          Activity

            People

              melix Cédric Champeau
              tim_yates Tim Yates
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: