[Mozile] save problem
Max d'Ayala
max at dayala.co.uk
Fri Oct 20 02:56:30 PDT 2006
Sending back the mozile XML part is probably the best way, but for
minimal testing you can use the 204 response which doesn't require any
body content.
This is a minimal PHP saving script. One other point worth bearing in
mind is that you need to strip the leading and trailing CR/LF pair every
time, otherwise you will add these every time you save.
<?php
// Minimal PHP POST save
//Get raw POST data.
$raw_post = file_get_contents('php://input');
//Strip CR/LF pair from beginning and end of data.
$save_data = substr($raw_post, 2, strlen($raw_post)-4);
$f = fopen( "temp.html", "wb" );
fwrite($f, $save_data, strlen($save_data));
//Send minimal reply (header only) to show that save was ok.
// 204 No Content
header('HTTP/1.1 204');
//Or this if you only have HTTP 1.0
//header('HTTP/1.0 204');
?>
===========================
I have a question of my own. I've noticed with the 0.6 version that I
don't get any messages in the status bar any more after saving. Is this
still working for other people in any of the Mozile versions? I'm
testing with Fx 1.5.0.7.
Thanks,
Max
James A. Overton wrote:
> Mozile is expecting to receive a bit of XML in reply to the POST,
> which will provide any error or status messages. See the
> documentation here:
> http://mozile.mozdev.org/0.7/modules/HTTPPost/PostSave05.htm
> and the examples in the 0.7/modules/HTTPPost/PHPdemo/ directory.
>
> Here is a sample OK response:
>
> <mozile xmlns="http://www.mozile.mozdev.org/ns/save/">
> <post>
> <status>1</status>
> <statustext>Saved OK</statustext>
> </post>
> </mozile>
>
> Your PHP script can output that and Mozile will be happy.
>
> James
>
>
> On 2006-Oct-19, at 3:37 AM, Michael Felden wrote:
>
>
>> Hi Max and everybody else,
>> thanks for your help - save works now!
>>
>> $f = fopen('test.htm','w');
>> fputs($f, file_get_contents('php://input'));
>> fclose($f);
>>
>> But mozile still thinks something's wrong.
>> I get 4 red status 3 messages:
>>
>> Beginning save...
>> Save via HTTP POST: 1. Initialising ...
>> Save via HTTP POST: 1. Sending ...
>> Save Failed! Unextpected server response ...
>>
>> Maybe you can help me with that too?
>>
>> Regards
>> Michael
>>
>
> _______________________________________________
> Mozile mailing list
> Mozile at mozdev.org
> http://mozdev.org/mailman/listinfo/mozile
>
>
More information about the Mozile
mailing list