Jump to content

http body length questions


BlueXBeta
 Share

You are about to reply to a thread that has been inactive for 752 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

hi

I run into the issue that the body of my httpRequest seems to be truncated at around 2048 characters.

The HTTP_METHOD is set to POST

 HTTP_BODY_MAXLENGTH to 16384

and the HTTP_MIMETYPE to "text/plain;charset=utf-8"

yet. the text arrives incomplete. I'm trying to trouble shoot where it is being truncated. But i can't find a tool to measure the actual byte size of the arriving body. 

 

thanks for any pointers towards how to get more characters into one body. 

 

best

 

Link to comment
Share on other sites

Quote

key httprequest(string page,string MSG)
{
    return llHTTPRequest(page,[
                HTTP_METHOD, "POST",
                //HTTP_MIMETYPE,"application/xhtml+xml",
                HTTP_MIMETYPE,"text/plain;charset=utf-8",
                HTTP_BODY_MAXLENGTH,16384,
                HTTP_VERIFY_CERT,FALSE,
                HTTP_VERBOSE_THROTTLE,FALSE,
                //HTTP_CUSTOM_HEADER,"","",
                HTTP_PRAGMA_NO_CACHE,TRUE
                            ],MSG);
}

it's just that. very simple. 

Link to comment
Share on other sites

Hmm, there doesn't seem to be anything wrong with that - although using method "POST" seems like an odd choice given that a response is expected.

As part of your http_response event, try reading back the character length of the body with llStringLength to double check that the string isn't being truncated elsewhere in the script or by an LSL quirk.

You may also find reading the metadata in the http_response event useful, as you can find where (if any) the body was truncated.

Edited by Jenna Huntsman
Link to comment
Share on other sites

24 minutes ago, panterapolnocy said:

1. Make sure that your script is saved as Mono and not LSO.
2. What does the llOwnerSay((string)llStringLength(body)) for response body in http_response reports?

thanks

the script is in mono. 

The StringLength reports a number of 1900. 

there are some special characters in there, but the vast majority of characters is numbers and texts. 

But am I correct that these settings I have (MAXLENGTH 16384) should allow for a lot more text to come through ? I'm suspecting also a truncating on the server side somewhere. 

Edited by BlueXBeta
?
Link to comment
Share on other sites

17 minutes ago, Jenna Huntsman said:

Hmm, there doesn't seem to be anything wrong with that - although using method "POST" seems like an odd choice given that a response is expected.

As part of your http_response event, try reading back the character length of the body with llStringLength to double check that the string isn't being truncated elsewhere in the script or by an LSL quirk.

You may also find reading the metadata in the http_response event useful, as you can find where (if any) the body was truncated.

POST is fine. I'm sending commands to a php file and that is responding back with data. Seems a bit safer to keep these commands and links hidden inside a body. 

Link to comment
Share on other sites

10 hours ago, Jenna Huntsman said:

Hmm, there doesn't seem to be anything wrong with that - although using method "POST" seems like an odd choice given that a response is expected.

As part of your http_response event, try reading back the character length of the body with llStringLength to double check that the string isn't being truncated elsewhere in the script or by an LSL quirk.

You may also find reading the metadata in the http_response event useful, as you can find where (if any) the body was truncated.

I am not getting any metadata. nor a body in the http_response event. I do receive a 200 from the server. but that's it. 

All the data that I am requesting from the server is being sent back as post and i receive it as body text in the http_request event. And THAT body is always truncated to 2048 chars, as I found out. i wonder if i am missing something in the process. 

but thanks for your help. 

Link to comment
Share on other sites

4 minutes ago, BlueXBeta said:

All the data that I am requesting from the server is being sent back as post and i receive it as body text in the http_request event. And THAT body is always truncated to 2048 chars, as I found out. i wonder if i am missing something in the process.

Ah, I see - I believe the issue there might be because the llHTTPRequest body length isn't actually expecting a response (i.e. the script sends data, then the server will 'reply', but not as part of the same transaction), the HTTP_BODY_MAXLENGTH doesn't apply. If using something like an HTTP GET, it would apply as the response is expected as part of the transaction.

Pinging @Monty Linden for confirmation of this hypothesis.

  • Thanks 1
Link to comment
Share on other sites

18 minutes ago, Jenna Huntsman said:

Ah, I see - I believe the issue there might be because the llHTTPRequest body length isn't actually expecting a response (i.e. the script sends data, then the server will 'reply', but not as part of the same transaction), the HTTP_BODY_MAXLENGTH doesn't apply. If using something like an HTTP GET, it would apply as the response is expected as part of the transaction.

Pinging @Monty Linden for confirmation of this hypothesis.

It seems that's where the issue is indeed. I understand the path from lsl script to the server, using the llHttpRequest with  "POST". Then the php script does its thing and using curl it POSTs back the result to my lsl script. But that body only shows up in the http_request event, truncated to 2048 chars. Nothing arrives in the http_response event.

How can I send back my data in such a way that it shows up in the http_respond event, which allows for a much larger body ? 

Link to comment
Share on other sites

  • Lindens

There are two bodies in a POST:  request and response.  LSL itself is the cap for the request body, you get about 32K characters there.  The response body size is limited by HTTP_BODY_MAXLENGTH whose maximum varies based on script VM.  That second one appears to be working as spec'd.  This script shows the 4K and 16K limits working and is based on your POST pattern:

key make_request()
{
    return llHTTPRequest("http://www.bing.com",
                        [
                HTTP_METHOD, "POST",
                HTTP_MIMETYPE, "text/plain;charset=utf-8",
                // HTTP_BODY_MAXLENGTH, 4096,
                HTTP_BODY_MAXLENGTH, 16384,
                HTTP_VERIFY_CERT, FALSE,
                HTTP_VERBOSE_THROTTLE, FALSE,
                HTTP_PRAGMA_NO_CACHE, TRUE
                            ], "");
}

default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }

    touch_start(integer total_number)
    {
        llSay(0, "Touched.");
        make_request();
    }

    http_response(key id, integer status, list metadata, string body)
    {
        llSay(0, "Length of body: " + (string) llStringLength(body));
    }
}

Look to your web server for likely reasons.

  • Thanks 4
Link to comment
Share on other sites

3 hours ago, Monty Linden said:

There are two bodies in a POST:  request and response.  LSL itself is the cap for the request body, you get about 32K characters there.

Unless the target is a SL region server url, then with POST it is 2k bytes out, unless I'm high.

Edited by Lucia Nightfire
Link to comment
Share on other sites

  • Lindens
1 hour ago, BlueXBeta said:

That's what I'm finding too. the request body seems always 2k max. 

Since we're talking about request bodies, I modified the request:

key make_request()
{
    string payload = "1234567890" + llUnescapeURL("%0A") + "\n";
    payload = payload + payload + payload + payload; // 48
    payload = payload + payload + payload + payload; // 192
    payload = payload + payload + payload + payload; // 768
    payload = payload + payload + payload + payload; // 3072
    payload = payload + payload + payload + payload; // 12288

    return llHTTPRequest("http://www.example.com",
                        [
                HTTP_METHOD, "POST",
                //HTTP_MIMETYPE,"application/xhtml+xml",
                HTTP_MIMETYPE, "text/plain;charset=utf-8",
                // HTTP_BODY_MAXLENGTH, 4096,
                HTTP_BODY_MAXLENGTH, 16384,
                HTTP_VERIFY_CERT, FALSE,
                HTTP_VERBOSE_THROTTLE, FALSE,
                //HTTP_CUSTOM_HEADER,"","",
                HTTP_PRAGMA_NO_CACHE, TRUE
                            ], payload);
}

And captured the outbound:

POST http://www.example.com/ HTTP/1.1
Host: www.example.com
... more headers ...
X-SecondLife-Owner-Name: Monty Linden
X-SecondLife-Region: LindenWorld B (237824, 244224)
X-SecondLife-Shard: Production
Content-Length: 12288

1234567890

1234567890

1234567890

1234567890

1234567890
...

 

  • Thanks 1
Link to comment
Share on other sites

10 minutes ago, Monty Linden said:

Since we're talking about request bodies, I modified the request:

And captured the outbound:

POST http://www.example.com/ HTTP/1.1
Host: www.example.com
... more headers ...
X-SecondLife-Owner-Name: Monty Linden
X-SecondLife-Region: LindenWorld B (237824, 244224)
X-SecondLife-Shard: Production
Content-Length: 12288

1234567890

1234567890

1234567890

1234567890

1234567890
...

 

But that is an outgoing body from LSL --> server. The cap happens when I send data from php ---> lsl 

 http_request(key id, string method, string body)
    {
        if (method=="POST") // incoming from server
        {   
                       llOwnerSay("SERVER: body length"+((string)llStringLength(body)));

 

this is always truncated to 2048 characters. in my case. 

 

Link to comment
Share on other sites

Alright. Thanks for the exploration. Seems I need to make a few post calls to collect the data I want. not a biggy I just thought I'm missing something. 

Confusion is still that there is the 16k body sitting in the respond event, but i'm getting stuck in the 2k body of the request event. Maybe I can send my data as a 'response' ? I need to test a bit what is possible on the php side. 

thanks! 

 

Link to comment
Share on other sites

5 hours ago, Monty Linden said:

Ah, that's http-in, a different pathway.  Yes, that's limited to 2K request bodies.  https://wiki.secondlife.com/wiki/LSL_HTTP_server#Other_Limitations

Am I reading something wrong or is the wiki badly worded?

https://wiki.secondlife.com/wiki/LlHTTPRequest - "Sets the maximum (UTF-8 encoded) byte length of the HTTP response body."
https://wiki.secondlife.com/wiki/HTTP_BODY_MAXLENGTH - "Used with llHTTPRequest to set the maximum size the script will accept for an HTTP body."
https://wiki.secondlife.com/wiki/LSL_HTTP_server#Other_Limitations - "Size of the body of the requests will be limited to 2k bytes."

The last one seems to contradict the previous two. As in, the first two sound like they'd affect how much content the script will accept in response to the request.

Edited by Wulfie Reanimator
Link to comment
Share on other sites

  • Lindens

The wiki needs love and a lot of it.  The first two refer to http-out, the last to http-in.  And the second is ambiguous.

There are four bodies involved:  http-in request, http-in response, http-out request, and http-out response.  Six if you include xmlrpc but please don't.  We are going to remove it someday.  Those bodies have different limits on them and this information is not clearly presented.  And then those limits double in number because we made the limits under mono slightly different than under lsl2. 

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

2 hours ago, Monty Linden said:

The wiki needs love and a lot of it.  The first two refer to http-out, the last to http-in.  And the second is ambiguous.

There are four bodies involved:  http-in request, http-in response, http-out request, and http-out response.  Six if you include xmlrpc but please don't.  We are going to remove it someday.  Those bodies have different limits on them and this information is not clearly presented.  And then those limits double in number because we made the limits under mono slightly different than under lsl2. 

Wiki has been updated to reflect this information, is much more concise about the truncation of body lengths between pipelines.

  • Like 2
Link to comment
Share on other sites

  • Lindens
2 hours ago, Jenna Huntsman said:

Wiki has been updated to reflect this information, is much more concise about the truncation of body lengths between pipelines.

Thanks!  The http-in really needs work.  The text is left over from the development phase and I can actually hear the developers' specific voices when I read it.  :)

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 752 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...