0
J'ai utilisé Poster addon pour firefox pour envoyer un POST xml. Ceci est l'en-tête HTTP capturé à partir d'un POST réussi sur un serveur hudson. J'essaye de reproduire ceci en php using la fonction d'en-tête().hudson: comment POSTER ce fichier XML après un post réussi?
POST /createItem?name=tellme HTTP/1.1
Host: somewhere.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: text/xml
Content-Length: 715
Cookie: JSESSIONID=69b4cb38635ae490d357bb6b21372507
Pragma: no-cache
Cache-Control: no-cache
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Shell>
<command></command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers>
<hudson.plugins.xvnc.Xvnc>
<takeScreenshot>false</takeScreenshot>
</hudson.plugins.xvnc.Xvnc>
</buildWrappers>
</project>
Voici mon code php:
<?php
$data = file_get_contents("config.xml");
$post_data = $data;
$content_length = strlen($post_data);
header('POST /createItem?name=friends HTTP/1.1');
header('Host: somewhere.com');
header('Keep-Alive: 115');
header('Connection: keep-alive');
header('Content-type: text/xml');
header('Content-length: ' . trim($content_length));
header($post_data);
exit();
Le code php échoue et lance: Warning: Header may not contain more than a single header, new line detected. Line 18.