|
Jez Ember
Registered User
Join date: 1 Feb 2008
Posts: 2
|
07-14-2009 09:54
I'm changing my product update server for http-in and conveniently my store is on one of the pilot rollout sims. The problem I have is that the body passed to http_request for both GET and POST methods is blank. e.g.: http_request(key id, string method, string body) { [omitted URL response code which works fine] if(method == "GET" || "METHOD" == "POST"  { llSay(0,"Request=" + body); llHTTPResponse(id, 200, "Request = " + body); } } Outputs a blank body in both local chat and in the http response. Therefore I cannot pass any parameters into the request. What am I missing? Cheers Jez PS Sorry for the formatting, doesn't seem to be any UBB support
|
|
Jez Ember
Registered User
Join date: 1 Feb 2008
Posts: 2
|
07-14-2009 10:05
To answer my own question.. llGetHTTPHeader is the call required to return the data I need. Fundamental misunderstanding to blame. EDIT Unfortunately this still doesn't help as a url with ?param=value formatting causes the SL server to "Internal Server Error". The request doesn't seem to get as far as my script. Is this is a known issue? i.e. http://sim5294.agni.lindenlab.com:12046/cap/nnnnnnnn?param1=value(where the URL is otherwise valid and current) produces: 500 Internal Server Error However http://sim5294.agni.lindenlab.com:12046/cap/nnnnnnnn/path1/path2/etcWorks just fine. Jez
|
|
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
|
07-14-2009 20:55
I encountered the same error when passing parameters. The stupid solution I found is to add a "/" before the "?". http://sim5294.agni.lindenlab.com:12046/cap/nnnnnnnn/?param1=valuellGetHTTPHeader(id, "x-path-info"  will just return "/" instead of an empty string but it works. As for the empty body, from my experiences from prim to prim, the body is transmitted for PUT and POST methods. This must be set explicitely in the llHTTPRequest() of which the default method is GET. Request = llHTTPRequest(URL, [HTTP_METHOD, "POST"], body); But, as you said, the parameters on the URL must be retrieved with: string params = llGetHTTPHeader(id, "x-query-string"  ;
|
|
Tali Rosca
Plywood Whisperer
Join date: 6 Feb 2007
Posts: 767
|
07-15-2009 02:17
There is an explanation for the "stupid" solution: The prim address as returned by llRequestURL is the root of a path, not a resource in itself. That makes sense, since you can use something like http://sim5294.agni.lindenlab.com:12046/cap/nnnnnnnn/myfolder/myresult, REST-style. That means that http://sim5294.agni.lindenlab.com:12046/cap/nnnnnnnn is trying to access the nnnnnnnn item in the cap folder, which doesn't exist, whereas http://sim5294.agni.lindenlab.com:12046/cap/nnnnnnnn/ is accessing the default item in the nnnnnnnn folder. ?something is the query parameters given to the resource identified by the full path. And yes, the body is only relevant in PUT and POST; GET cannot have a body by official standard. GET gets what's already there, nothing more. Giving extra information in a body doesn't make sense. PUT puts the contents of the body at the given address; a fairly rare use unless you're uploading documents/data REST-style (and works in tandem with DELETE), and POST hands some parameters or data to a specific resource, to do with as it pleases. A common style of POST is the "application/x-www-form-urlencoded" encoding which mimics the tag1=value1&tag2=value2 format of URL query parameters. (Of course, you can mangle the PUT and POST semantics as badly as you want. Fundamentally, they are just a name sent to the server, but this is the definition of their intended use).
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
07-15-2009 10:40
Are you sure it's not getting as far as your script? If you are using POST, there's a problem in your logic: if(method == "GET" || "METHOD" == "POST") ...
Note that "METHOD" == "POST" will ALWAYS be false. The second term in the logic expression needs to look more like the first.
|