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

create simple http client

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Abandoned
    • None
    • None
    • groovy-jdk
    • None

    Description

      The idea is to create a simple http client based only on current groovy abilities.

      Code example:

      def r = HTTP.get(
        url : 'https://www.googleapis.com/customsearch/v1',
        query: [ q: 'hello world' ],
        headers: [
          'Accept':'application/json',
          //'Authorization' : ...,
        ],
        //optional - ssl context 
        ssl : getNaiveSSLContext(),
        //optional - receiver
        receiver : { stream,context -> new JsonParser().parse(stream) },
        //optional - body to perform data transfer (post/put/... http methods) 
      )
      assert r.response.code == 200
      println r.response.body
      

      I suggest to integrate this class (attached) into groovy.
      Before opening a pull request I'd like to know opinion of the language owners/gurus: is it ok? or maybe this functionality repeats something, that i missed/

      Attachments

        1. HTTP.groovy
          9 kB
          Dmitry Lukyanov

        Activity

          People

            Unassigned Unassigned
            dlukyanov Dmitry Lukyanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m