Discussion:
(XML-RPC) HTTP/1.0 400 BadRequest: Invalid request line
Jeff Kelley
2014-10-22 22:48:17 UTC
Permalink
Dear developers.

I use XML-HTTP with success, except a HTTP 400 error is appended to
the (otherwise correct) XML response. Example:

llRemoteDataReply(channel, message_id, "Je vous ai compris", 42);

My PHP program reads:

<?xml version="1.0"
encoding="utf-8"?><methodResponse><params><param><value><array><data><value><struct><member><name>IntValue</name><value><i4>42</i4></value></member><member><name>StringValue</name><value><string>Je
vous ai
compris</string></value></member></struct></value></data></array></value></param></params></methodResponse>HTTP/1.0
400 BadRequest: Invalid request line.

I can strip the extra data and go as-is, but I would prefer to
understand what triggers "Invalid request line" to fix my code.

Can you help?

-- Jeff



Full PHP code:


<?php
$req_url = 'http://192.168.0.6:20800/';

$request = xmlrpc_encode_request('llRemoteData',
array ('Channel' => '71c0838f-fb8c-4c5d-a500-9dae4298243d',
'IntValue' => 117,
'StringValue' => 'GABUZO')
);

$context = stream_context_create(array('http' => array(
'method' => "POST",
'header'=> "Content-type: text/xml\r\n"
"Content-length: ".strlen($request)."\r\n",
'content' => $request
)));

$file = file_get_contents($req_url, false, $context);

$lastbracket = strrpos($file, '>');
$extra = substr ($file, $lastbracket+1,-1);
$file = substr ($file, 0, $lastbracket+1);

$answer = xmlrpc_decode($file);

print_r ($answer);
?>

Array
(
[0] => Array
(
[IntValue] => 42
[StringValue] => Je vous ai compris
)

)
Justin Clark-Casey
2014-10-22 23:14:54 UTC
Permalink
My guess is that this could just be an OpenSimulator bug, though I'm surprised it hasn't shown up before. I presume
this always happens to you?

Could you open a Mantis with the PHP and the LSL script code if possible?

-- Justin
Post by Jeff Kelley
Dear developers.
llRemoteDataReply(channel, message_id, "Je vous ai compris", 42);
<?xml version="1.0"
encoding="utf-8"?><methodResponse><params><param><value><array><data><value><struct><member><name>IntValue</name><value><i4>42</i4></value></member><member><name>StringValue</name><value><string>Je
vous ai
compris</string></value></member></struct></value></data></array></value></param></params></methodResponse>HTTP/1.0 400
BadRequest: Invalid request line.
I can strip the extra data and go as-is, but I would prefer to understand what triggers "Invalid request line" to fix my
code.
Can you help?
-- Jeff
<?php
$req_url = 'http://192.168.0.6:20800/';
$request = xmlrpc_encode_request('llRemoteData',
array ('Channel' => '71c0838f-fb8c-4c5d-a500-9dae4298243d',
'IntValue' => 117,
'StringValue' => 'GABUZO')
);
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header'=> "Content-type: text/xml\r\n"
"Content-length: ".strlen($request)."\r\n",
'content' => $request
)));
$file = file_get_contents($req_url, false, $context);
$lastbracket = strrpos($file, '>');
$extra = substr ($file, $lastbracket+1,-1);
$file = substr ($file, 0, $lastbracket+1);
$answer = xmlrpc_decode($file);
print_r ($answer);
?>
Array
(
[0] => Array
(
[IntValue] => 42
[StringValue] => Je vous ai compris
)
)
_______________________________________________
Opensim-dev mailing list
http://opensimulator.org/cgi-bin/mailman/listinfo/opensim-dev
--
Justin Clark-Casey (justincc)
OSVW Consulting
http://justincc.org
http://twitter.com/justincc
Jeff Kelley
2014-10-22 23:55:32 UTC
Permalink
Post by Justin Clark-Casey
My guess is that this could just be an OpenSimulator bug, though I'm surprised
it hasn't shown up before. I presume this always happens to you?
I'm just beginning with XML-RPC (I need stable addresses, which
llRequestURL are not). But yes, I have the error 400 each time.
Post by Justin Clark-Casey
Could you open a Mantis with the PHP and the LSL script code if possible?
This will be done tomorrow.

Thanks for caring.

-- Jeff
Jeff Kelley
2014-10-23 23:54:21 UTC
Permalink
Post by Justin Clark-Casey
Could you open a Mantis with the PHP and the LSL script code if possible?
Finally, I won't MANTIS this because it is more a
PHP issue than an opensim issue.

Using file_get_contents, I have different wrong
results with PHP 5.3 and PHP 5.5.
extra «HTTP/1.0 400 BadRequest: Invalid request line » appended to the XML,
_or_ non-closing connection even vith « Connection: Close ».

However, I have a correct behavior in both cases
using cURL instead of file_get_contents.

I made the wrong asumption that
llOpenRemoteDataChannel uuid's were stable. They
are, until you reboot the simulator. Which gives
XML-RPC absolutely no advantage over HTTP server
(llRequestURL). Both need an external tracker.


-- Jeff

Loading...