Ant 的 RESTful httpclient

发布于 08-23 03:33 字数 117 浏览 8 评论 0原文

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

与 contrib 相关的任务似乎都不再起作用了。

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

瀞厅☆埖开2024-08-30 03:33:39

尝试使用 Ant exec 任务和 curl

Try using an Ant exec task and curl.

倚栏听风2024-08-30 03:33:39

我已经使用 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>

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>
慢慢从新开始2024-08-30 03:33:39

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

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

这里有它的用户吗?

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?

那一片橙海,2024-08-30 03:33:39

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文