开发者

RESTful httpclient for Ant

开发者 https://www.devze.com 2022-12-21 08:17 出处:网络
I need a RESTful httpclient for Ant. None of the开发者_开发技巧 contrib related tasks seem to work anymore..

I need a RESTful httpclient for Ant.

None of the开发者_开发技巧 contrib related tasks seem to work anymore..

Hasn't anyone bridged Commons-HTTPClient and Ant yet?


Try using an Ant exec task and curl.


I have used CURL from ANT to POST files with the following macrodef:

<pathconvert property="curl.path" targetos="windows">
    <path location="${lib.dir}/curl/curl.exe"/>
</pathconvert>
<macrodef name="post-file" description="Use Curl to post the file to the WEBDAV path">
    <attribute name="file"/>
    <attribute name="url" />    
    <attribute name="username" default="${username}" />
    <attribute name="password" default="${password}" />
    <sequential>
        <echo message="Using CURL to upload @{file} to @{url}" />
        <!--Execute curl to post the file to the URL -->
        <exec executable="${curl.path}">
            <arg value='-L'/>
            <arg value='-k'/>
            <arg value='-f'/>
            <arg value='-s'/>
            <arg value="--anyauth"/>
            <arg value="-u"/>
            <arg value="@{username}:@{password}"/>              
            <arg value="-T" />
            <arg value='"@{file}"' /> 
            <arg value='@{url}'/>  
        </exec>
    </sequential>
</macrodef>

Execute the macrodef like this:

<target name="test-upload">
        <post-file file="${file}" 
                   url="${url}" 
                   username="${username}" 
                   password="${password}" />
    </target>


I found this project http://fikin-ant-tasks.sourceforge.net/.

Last file update is 2007-03-12 so Im a bit worried about quality...

any users of it here?


There's an http post task in Antelope but it doesn't seem to support Basic Authentication. :/

0

精彩评论

暂无评论...
验证码 换一张
取 消