蚂蚁的获取任务抛出 IOException



我正在设置一个蚂蚁任务,以调查我的应用程序,以获取健康状态,此任务的输出应简单地从端点显示JSON输出,这就是我尝试过

<target name="status">
    <get src="http://127.0.0.1:8840/-/system/get_health" dest="${dir.tmp}/status" />
    <loadfile property="status" srcFile="${dir.tmp}/status" />
    <echo message="${status}" />
</target>

以上是在get

上丢下以下错误

[获取]获取:http://127.0.0.1:8840/-/system/get_health
[获取]到:c: path to build tmp status
[获取]错误打开连接java.io.ioexception:无效的http响应
[get]无法获取http://127.0.0.1:8840/-/-/system/get_health到C: Path to build tmp tmp status

get期望返回的格式到底是什么?

据我所知,这是纯文本输出,没有标题。

i可以用curl和使用Chrome查看输出。

$curl http://127.0.0.1:8840/-/system/get_health
{"status": "HEALTHY"}

是否有任何方法可以忽略此错误并保存输出?还是有另一种方法可以做?

编辑

运行
$ant status -debug

没有提供有用的输出,而其他已经发布的输出。

$curl -v http://127.0.0.1:8840/-/system/get_health
* STATE: INIT => CONNECT handle 0x6000578b0; line 1108 (connection #-5000)
* Added connection 0. The cache now contains 1 members
*   Trying 127.0.0.1...
* STATE: CONNECT => WAITCONNECT handle 0x6000578b0; line 1161 (connection #0)
* Connected to 127.0.0.1 (127.0.0.1) port 8840 (#0)
* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x6000578b0; line 1260 (connection #0)
* STATE: SENDPROTOCONNECT => DO handle 0x6000578b0; line 1278 (connection #0)
> GET /-/system/get_health HTTP/1.1
> Host: 127.0.0.1:8840
> User-Agent: curl/7.48.0
> Accept: */*
>
* STATE: DO => DO_DONE handle 0x6000578b0; line 1357 (connection #0)
* STATE: DO_DONE => WAITPERFORM handle 0x6000578b0; line 1484 (connection #0)
* STATE: WAITPERFORM => PERFORM handle 0x6000578b0; line 1494 (connection #0)
* Increasing bytecount by 23 from hbuflen
{"status": "HEALTHY"}
* nread <= 0, server closed connection, bailing
* STATE: PERFORM => DONE handle 0x6000578b0; line 1652 (connection #0)
* Curl_done
* Connection #0 to host 127.0.0.1 left intact
* Expire cleared

尝试在这里查看。这可能是由于返回值中的特殊字符。字符串需要编码。

有趣的是,我正在使用的Web插座处理程序中的执行不佳,因为它实际上从未返回响应中的状态行。

我不得不辍学到使用NetCat来查看服务器的原始数据:

$ echo -e "GET /-/system/get_health HTTP/1.1nn" | nc 127.0.0.1 8840
{"status": "HEALTHY"}
$

不应该适合适当的http规格

$ echo -e "GET /-/system/get_health HTTP/1.1nn" | nc 127.0.0.1 8840
HTTP/1.1 200 OK
{"status": "HEALTHY"}
$

这很奇怪,因为Chrome和Curl似乎都盲目地忽略了它。

固定后,蚂蚁解析响应没有问题。

相关内容

最新更新