Jump to content

How to implement content-range header in llHTTPRequest


Gayngel
 Share

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

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

Recommended Posts

The wiki for llHTTPRequest says you can set a custom range of data returned with the content-range custom header. I've tried implementing the header in a request but it just returns the whole data instead of the range. I think I;m not writing it correctly or something.

 

llHTTPRequest(url,[HTTP_BODY_MAXLENGTH,16384,HTTP_CUSTOM_HEADER,"Content-Range","bytes 3440-6900/*", HTTP_METHOD,"POST"],"");

 

Edited by Gayngel
Link to comment
Share on other sites

9 hours ago, Quistess Alpha said:

Perhaps the server is ignoring your request to reply with a specific range because you're using a POST request? did you try with GET?

Even with GET I'm getting the same result, it's just returning all the text instead of the range.

  • Thanks 1
Link to comment
Share on other sites

Content-Range is being ignored when I test it, too (edited to add: maybe the function doesn't consider it an allowed custom header?).

Edited again since reading is hard: the Mozilla docs actually say Content-Range is a *response* header, not request. The Range is a *request* header and works, at least somewhat. Some servers will return unusable garbage, looks like a character set issue that I didn't try to circumvent.

E.g.

default
{
    state_entry() {
        llHTTPRequest("https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range",
        [HTTP_BODY_MAXLENGTH,16384,HTTP_CUSTOM_HEADER,"Range","bytes=3-99"],
        "");
    }
    http_response(key id, integer status, list meta, string data) {
        llOwnerSay((string)status);
        llOwnerSay((string)llStringLength(data));
        llOwnerSay(data);
    }
}

 

Edited by Frionil Fang
  • Thanks 2
Link to comment
Share on other sites

9 hours ago, Quistess Alpha said:

Perhaps the server is ignoring your request to reply with a specific range because you're using a POST request? did you try with GET?

That was my thought also.  (Although admittedly, I've used llHTTPRequest() with only one set of scripts so far.)

 

Link to comment
Share on other sites

4 hours ago, Frionil Fang said:

Content-Range is being ignored when I test it, too (edited to add: maybe the function doesn't consider it an allowed custom header?).

Edited again since reading is hard: the Mozilla docs actually say Content-Range is a *response* header, not request. The Range is a *request* header and works, at least somewhat. Some servers will return unusable garbage, looks like a character set issue that I didn't try to circumvent.

E.g.

default
{
    state_entry() {
        llHTTPRequest("https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range",
        [HTTP_BODY_MAXLENGTH,16384,HTTP_CUSTOM_HEADER,"Range","bytes=3-99"],
        "");
    }
    http_response(key id, integer status, list meta, string data) {
        llOwnerSay((string)status);
        llOwnerSay((string)llStringLength(data));
        llOwnerSay(data);
    }
}

 

Thank you @Frionil Fang . I stuck your script in a new prim and it worked at first but if I try edit the range it just returns status 200 & the max length of chars again. If I change the range back to yours it also returns status 200 & the max length of chars again. It seems to be buggy.

Edit: From reading the docs and elsewhere I think it might always work if we can get the right HTTP_MIMETYPE and/or the right mix of range and content-range.

Edited by Gayngel
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 448 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...