PHP / pear http put方法和text / xml? [英] PHP/pear http put method and text/xml?

查看:59
本文介绍了PHP / pear http put方法和text / xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我对PEAR包的HTTP实现有问题:

我尝试将XML实例PUT到XML数据库( eXist),但它总是

放一个二进制文件:


<?php

require_once" HTTP / Request.php" ;;


$ URL =''http://ap34.ifi.informatik.uni-goettingen.de:8081/exist/servlet/db/may/hamlet.xml'' ;


$ req =&新的HTTP_Request("");

$ req-> setBasicAuth($ user,$ passwd);

$ req-> setURL($ URL);

$ req-> setMethod(" PUT");

$ req-> addHeader(" Content-Type"," text / xml") ;

$ req-> addFile(" hamlet.xml"," /home/may/public_html/PHP/hamlet.xml"," text / xml");


$ response = $ req-> sendRequest();

?>


查看数据库时,还有XML文件,但

有一个完整的HTTP请求:


***

--HTTP_Request_f42cc34621bc820ecd46b8f6ef61eb7e

Content-Disposition:form-data;命名= QUOT; Hamlet.xml用英寸; filename =" hamlet.xml"

内容类型:text / xml

<?xml version =" 1.0"?>

<!DOCTYPE PLAY SYSTEM" play.dtd">


< PLAY>

< TITLE>哈姆雷特,丹麦王子的悲剧< / TITLE>



****


似乎不是数据库的一个问题,因为它在使用python(eXist文档中包含的一个示例)时与它相同时工作得很好,

即数据库工作当它收到正确的PUT时正确。

有人能给我一个如何用PEAR正确应用HTTP PUT的例子吗?


THX,

Wolfgang

Hi,

I have a problem with the HTTP implementation of the PEAR package:
I try to PUT an XML instance to an XML database (eXist), but it always
puts a binary:

<?php
require_once "HTTP/Request.php";

$URL = ''http://ap34.ifi.informatik.uni-goettingen.de:8081/exist/servlet/db/may/hamlet.xml'';

$req =& new HTTP_Request("");
$req->setBasicAuth($user, $passwd);
$req->setURL($URL);
$req->setMethod("PUT");
$req->addHeader("Content-Type", "text/xml");
$req->addFile("hamlet.xml","/home/may/public_html/PHP/hamlet.xml", "text/xml");

$response = $req->sendRequest();
?>

When looking into the database, there is also not the XML file, but
there is a complete HTTP request:

***
--HTTP_Request_f42cc34621bc820ecd46b8f6ef61eb7e
Content-Disposition: form-data; name="hamlet.xml"; filename="hamlet.xml"
Content-Type: text/xml

<?xml version="1.0"?>
<!DOCTYPE PLAY SYSTEM "play.dtd">

<PLAY>
<TITLE>The Tragedy of Hamlet, Prince of Denmark</TITLE>
etc.
****

It seems not ot be a problem of the database, since it works well when doing
the same with python (a sample that is included into the documentation of eXist),
i.e., tha database work correctly when it receives a correct PUT.
Can anybody give me an example how HTTP PUT is applied correctly with PEAR?

THX,
Wolfgang

推荐答案

URL =''http://ap34.ifi.informatik.uni-goettingen.de:8081/exist/servlet /db/may/hamlet.xml'';

URL = ''http://ap34.ifi.informatik.uni-goettingen.de:8081/exist/servlet/db/may/hamlet.xml'';


req =&新的HTTP_Request(");
req =& new HTTP_Request("");


req-> setBasicAuth(
req->setBasicAuth(


这篇关于PHP / pear http put方法和text / xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆