Grokbase Groups Ant user March 2016
FAQ
Hello,

in our ant script, we use the "get" task to fetch some data from the server via HTTP GET. The server interprets the 'Content-Type' header of the request and delivers the response in the appropriate format (html/xml/json).

We'd like to have the result as XML and hence would need to set the content type header of the HTTP request.

Is this possible using the standard get task? If yes, how?

I've only found the 'useragent' attribute in the task but no means to set some other HTTP headers.

Thanks!
AL

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

Search Discussions

  • Scot P. Floess at Mar 17, 2016 at 2:43 am
    I've kept your email in my inbox wanting to see if I could help.

    Now that I'm trying - I'm surprised you can't specify the Content-Type. I
    do a fair bit of REST work so I absolutely understand your desire for this
    functionality. I found ant-contrib has a post task but that won't help
    you.

    Might be worth submitting a feature request or write something in a
    scripting language (my go-to is usually Beanshell). However maybe
    Javascript? Essentially put a script-def in place in your ant script.

    There maybe better solutions but I noted nobody responded to date - so
    thought I'd give my $0.02.

    Probably pretty easy to add this via a script-def...let me know if it
    doesn't make sense or you are curious...

    On Wed, 16 Mar 2016, Al Le wrote:

    Hello,

    in our ant script, we use the "get" task to fetch some data from the server via HTTP GET. The server interprets the 'Content-Type' header of the request and delivers the response in the appropriate format (html/xml/json).

    We'd like to have the result as XML and hence would need to set the content type header of the HTTP request.

    Is this possible using the standard get task? If yes, how?

    I've only found the 'useragent' attribute in the task but no means to set some other HTTP headers.

    Thanks!
    AL

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
    Scot P. Floess RHCT (Certificate Number 605010084735240)
    Chief Architect FlossWare http://sourceforge.net/projects/flossware
                                 http://flossware.sourceforge.net
                                 https://github.com/organizations/FlossWare

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Tom Cleghorn at Mar 17, 2016 at 10:48 am
    We've found the missing-link tasks to be really helpful - doesn't appear
    to be under active development any more though.
    https://missinglinkcode.wordpress.com/ points to a dead Google Code repo
    now, but a recent comment from the developer points to
    https://github.com/alex-sherwin/missing-link/
    On 17/03/2016 06:43, Scot P. Floess wrote:

    I've kept your email in my inbox wanting to see if I could help.

    Now that I'm trying - I'm surprised you can't specify the
    Content-Type. I do a fair bit of REST work so I absolutely understand
    your desire for this functionality. I found ant-contrib has a post
    task but that won't help you.

    Might be worth submitting a feature request or write something in a
    scripting language (my go-to is usually Beanshell). However maybe
    Javascript? Essentially put a script-def in place in your ant script.

    There maybe better solutions but I noted nobody responded to date - so
    thought I'd give my $0.02.

    Probably pretty easy to add this via a script-def...let me know if it
    doesn't make sense or you are curious...

    On Wed, 16 Mar 2016, Al Le wrote:

    Hello,

    in our ant script, we use the "get" task to fetch some data from the
    server via HTTP GET. The server interprets the 'Content-Type' header
    of the request and delivers the response in the appropriate format
    (html/xml/json).

    We'd like to have the result as XML and hence would need to set the
    content type header of the HTTP request.

    Is this possible using the standard get task? If yes, how?

    I've only found the 'useragent' attribute in the task but no means to
    set some other HTTP headers.

    Thanks!
    AL

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
    Scot P. Floess RHCT (Certificate Number 605010084735240)
    Chief Architect FlossWare http://sourceforge.net/projects/flossware
    http://flossware.sourceforge.net
    https://github.com/organizations/FlossWare

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org




    Cambridge University Press is the publishing business of the University of Cambridge with VAT registered number GB 823 8476 09. Our principal office is at University Printing House, Shaftesbury Road, Cambridge, CB2 8BS, United Kingdom.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Stefan Bodewig at Mar 17, 2016 at 4:58 am

    On 2016-03-16, Al Le wrote:

    We'd like to have the result as XML and hence would need to set the
    content type header of the HTTP request.
    Is this possible using the standard get task? If yes, how?
    No, the get task doesn't support setting the Accept-Header. The feature
    would be useful, but AFAIK you are the first person asking for it.

    Stefan

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Al Le at Mar 17, 2016 at 5:42 am

    No, the get task doesn't support setting the Accept-Header.
    Probably pretty easy to add this via a script-def...
    Thank you for the quick responses!

    I'll try it with JavaScript. I just wanted to make sure I didn't miss
    something. Basicly, I'll have to implement the get task in JavaScript
    (use Java classes from JavaScript) and add one more header, right?

    Still, I think that a possibility to specify HTTP headers (e.g. via
    nested elements) would be a useful addition to the get task.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Chris Barlock at Mar 17, 2016 at 1:50 pm
    Is curl an option? You can run it with the Ant exec task.

    Chris



    From: Al Le <al.le@gmx.de>
    To: Ant Users List <user@ant.apache.org>
    Date: 03/17/2016 02:33 AM
    Subject: Re: How to set content type in "get" task?


    No, the get task doesn't support setting the Accept-Header.
    Probably pretty easy to add this via a script-def...
    Thank you for the quick responses!

    I'll try it with JavaScript. I just wanted to make sure I didn't miss
    something. Basicly, I'll have to implement the get task in JavaScript
    (use Java classes from JavaScript) and add one more header, right?

    Still, I think that a possibility to specify HTTP headers (e.g. via
    nested elements) would be a useful addition to the get task.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Al Le at Mar 17, 2016 at 10:47 pm
    Is curl an option? You can run it with the Ant exec task.
    Yes, I already considered using curl or wget. It will be simpler than
    implementing the feature from scratch in JavaScript (or in some other
    language).

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesant
postedMar 16, '16 at 7:05p
activeMar 17, '16 at 10:47p
posts7
users5
websiteant.apache.org

People

Translate

site design / logo © 2018 Grokbase