3

我需要一个用于 Ant 的 RESTful httpclient。

与贡献相关的任务似乎都不再起作用了..

还没有人桥接 Commons-HTTPClient 和 Ant 吗?

4

4 回答 4

3

尝试使用 Ant 执行任务和curl

于 2010-03-01T08:26:17.923 回答
1

我已经使用 CURL 从 ANT 到具有以下宏定义的 POST 文件:

<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>

像这样执行宏定义:

<target name="test-upload">
        <post-file file="${file}" 
                   url="${url}" 
                   username="${username}" 
                   password="${password}" />
    </target>
于 2012-01-21T03:37:45.107 回答
0

我发现了这个项目http://fikin-ant-tasks.sourceforge.net/

最后一次文件更新是 2007-03-12 所以我有点担心质量...

这里有它的用户吗?

于 2010-03-01T09:58:32.457 回答
0

Antelope中有一个 http post 任务,但它似乎不支持基本身份验证。:/

于 2010-04-14T19:38:40.120 回答