XML 回车符在发布后消失了
我是Linux用户。 我有一个名为 config.xml 的 XML 文件。下面是文件的头部:
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<logRotator>
<daysToKeep>-1</daysToKeep>
<numToKeep>10</numToKeep>
...
我尝试使用以下方式发布它:
curl --user“USERNAME:PASSWORD”-X POST -d“@config.xml”-H“Content-Type:text/xml; charset = utf-8" http://example.com
config.xml 被发布,但内容不带回车符。例如:
<?xml version="1.0" encoding="UTF-8"?><project> <actions/> <description/> <logRotator> <daysToKeep>-1</daysToKeep> <numToKeep>10</numToKeep> ...
到目前为止已完成的测试:
我实际上运行了“od -tc config.xml”,原始文件包含“\r”字符,但发布的 xml 文件不包含它。
我尝试使用内容类型“application/xml”和“plain/text”发送它,但它仍然是相同的方式。 (我认为回车符可能会保留为二进制或 ascii 类型)
我尝试运行 unix2dos 来可能将“\n”添加到它所做的行的末尾(使用 od -tc 进行测试)但是它也不能解决问题。
请让我知道我是否应该做其他事情?
ps
如果有帮助,这与 Hudson 构建服务器和为已存在的任务发布 config.xml 文件有关。
谢谢
I'm a linux user.
I have an XML file call config.xml. below is the head of the file:
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<logRotator>
<daysToKeep>-1</daysToKeep>
<numToKeep>10</numToKeep>
...
I'm trying to post it using:
curl --user "USERNAME:PASSWORD" -X POST -d "@config.xml" -H "Content-Type: text/xml; charset=utf-8" http://example.com
the config.xml gets posted however the content comes out with out carriage return. such as:
<?xml version="1.0" encoding="UTF-8"?><project> <actions/> <description/> <logRotator> <daysToKeep>-1</daysToKeep> <numToKeep>10</numToKeep> ...
Tests that have been done so far:
I have actually ran "od -tc config.xml" and the original file contains the "\r" character however the posted xml file doesn't contain it.
I have tried sending it using the content type "application/xml" and "plain/text" but it is still the same way. (I thought maybe the carriage return would be preserved with the binary or ascii types)
I have tried to run unix2dos to maybe add "\n" to the end of the lines which it does (tested using od -tc) however it doesn't resolve the problem either.
Please let me know if I should do anything else?
ps
if it help, this is related to the hudson build server and posting config.xml file for a task that already exists.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要使用curl的-d(或--data)选项,而是使用保留文件的选项:
instead of using curl's -d (or --data) option, use the one that preserves the file: