XML 回车符在发布后消失了

发布于 2024-10-31 03:24:39 字数 1178 浏览 3 评论 0原文

我是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 技术交流群。

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

发布评论

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

评论(1

泪之魂 2024-11-07 03:24:39

不要使用curl的-d(或--data)选项,而是使用保留文件的选项:

   --data-binary <data>
          (HTTP) This posts data exactly as specified with no extra pro‐
          cessing whatsoever.

instead of using curl's -d (or --data) option, use the one that preserves the file:

   --data-binary <data>
          (HTTP) This posts data exactly as specified with no extra pro‐
          cessing whatsoever.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文