Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#34 Range request broken

open
nobody
5
2011-01-03
2011-01-03
Nimesh Chanchani
No

I'm using cyberlink with IPhone. The Cyberlink server is on an Android device and the client is MLPlayer Lite on IPhone. IPhone always requests byte ranges, but the cyberlink server seems send the response erronomously. See below only bytes 0-1 are requested but the server sends 0-1338457. GET /ExportContent?id=15 HTTP/1.1 Host: 192.168.0.100:38520 Range: bytes=0-1 Accept: */* Accept-Encoding: identity Connection: keep-alive User-Agent: AppleCoreMedia/1.0.0.8C148 (iPhone; U; CPU OS 4_2_1 like Mac OS X; en_us) HTTP/1.1 206 Partial Content Content-Type: video/mp4 Server: Linux/2.6.32.9-27240-gbca5320 CyberHTTP/1.0 Content-Length: 13384548 Content-Range: bytes 0-13384547/13384548 Date: Wed, 29 Dec 2010 01:39:28 GMT ... ftypmp42....mp42isom...........Kmoov...lmvhd......>K..>N...X....................................................@.................................p.trak...\tkhd......=...>N............................................................@..............$edts....elst......................p]mdia... mdhd......>K..>K..V".?.........:hdlr........soun............Apple Sound Media Handler...o.minf....smhd...........$dinf....dref............url ......o.stbl...gstsd...........Wmp4a........................V".....3esds........"........@......]...]..................stts..................#.stsc....................................................................................................................... ................................... ................................................................................................................................................................................................................................... ...........!..........."...........#...........$...........%...........&...........'...........(...........)...........*...........+...........,...........-......................./...........0...........1...........2...........3...........4...........5...........6...........7...........8...........9...........:...........;...........<...........=...........>...........?...........@...........A...........B...........C...........D...........E...........F...........G...........H...........I...........J...........K...........L...........M...........N...........O...........P...........Q...........R...........S...........T...........U...........V...........W...........X...........Y...........Z...........[...........\...........]...........^..........._...........`...........a...........b...........c...........d...........e...........f...........g...........h...........i...........j...........k...........l...........m...........n...........o...........p...........q...........r...........s...........t...........u...........v...........w...........x...........y...........z...........{...........|...........}...........~............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... ................................... ................................................................................................................................................................................................................................... ...........!..........."...........#...........$...........%...........&...........'...........(...........)...........*...........+...........,...........-......................./...........0...........1...........2...........3...........4...........5...........6...........7...........8...........9...........:...........;...........<...........=...........>...........?...........@...........A...........B...........C...........D...........E...........F...........G...........H...........I...........J...........K...........L...........M...........N...........O...........P...........Q...........R...........S...........T...........U...........V...........W...........X...........Y...........Z...........[...........\...........]...........^..........._...........`...........a...........b...........c...........d...........e...........f...........g...........h...........i...........j...........k...........l...........m...........n...........o...........p...........q...........r...........s...........t...........u...........v...........w...........x...........y...........z...........{...........|...........}...........~............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... ................................... ................................................................................................................................................................................................................................... ...........!..........."...........#...........$...........%...........&...........'...........(...........)...........*...........+...........,...........-......................./...........0...........1...........2...........3...........4...........5...........6...........7...........8...........9...........:...........;...........<...........=...........>...........?...........@...........A...........B...........C...........D...........E...........F...........G...........H...........I...........J...........K...........L...........M...........N...........O...........P...........Q...........R...........S...........T...........U...........V...........W...........X...........Y...........Z...........[...........\...........]...........^..........._...........`...........a...........b...........c...........d...........e...........f...........g...........h...........i...........j...........k...........l...........m...........n...........o...........p...........q...........r...........s...........t...........u...........v...........w...........x...........y...........z...........{...........|...........}...........~..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................?.stsz............... .......................................................................................................................................................................................................................................................................................................x.......................................{...............................................y.......................................|.......u...............|.......q...........}...z.......m...}...~...v...}...|...................~...........................................................................................................................................................................w...............................................z...x...l...}...........}...........................{...t...........t...x...............................................{...x...........v.......x...p...y...w...........r.......................................}...........w...............}.......................................................|...........z...{...|...|.......................}...z.......................................|...................................................x...........................................................~...................................................z.......u...s...................................z...y.......|...r.......s...x.......u.......|...~...y...x...................................................................................................................l.......................f...q...t...w...|...l...}.......}...................~...............p...................................................................................~...w...........v...t...........................y...............................................p...............r...............|...........................{...........v...k.......................................m...y.......|.......}...z.......w...p...~.......y...............}...y...~...........................................~...........................................................................................................................................x.......~...g...x.......................~...v...w...........x...p...g...u.......................................{...............................|...r...........................................v...k...k.......t...s...............................l...........~...q...r...q...p.......................................................................................................y.......q...z...............................................n...u...t...x.......~...................l.......w...}.......{...........~.......{...........x...............................................................................~.......~.......y...u...........}...u...................................................y...........................z...l...........v...{...............................u...........o...p...............x...o...|...~...................r...p...................................................................w...................................k.......................x...v...g...{...l...q...u...........|...............u...............}...{...........................................................................................w...j...z...i...........................u...............r...................z.......o...v...o.......~...u...................................................................................p.......~...x...........w...........x...w.......~...|.......w...................~...~...................................}...........y...y...............................................w...................................................................s...............u.......x...s...s...r...........t.......|...........x...........{.......{...n...~...............................}...................w...............q...................................|...............p...x...........................}.......o...w...y...........}.......~...~...q...v...................................~.......................~...........p...............................i...v.......u...........................m.......y...x...t...............................p...........t...t...............y...z...~...z...............................................................................................v...............~...x.......................|...s.......r...........{...................................z...........}...............................................................{...e...........t...}...........................r...........................~.......m...................y...y.......y...................................................u...............}...........q...v...................................}...............~...............................n...........................~...z.......................................................................~...}.......................................................z...}.......t.......q.......................n...............................................................f...................................{...i...x...k.......|...}...}...............r...........x...}.......y...........................x...............................}...........~...............z...................y...............x...y.......t...................................t...................|.......{.......s.......u...........................y...............................................z...................}...{...|...................}...............x...........................................................e...........u.......z.......................o...~...........r...{...........................................................q.......l...t...}...............{...............t.......o...........t...}.......{...............................................................w...............................u...~...~.......}...|...................................t...{...}.......|...~...........................~...............}...................................................................................................................................................~.......................................................q.......t...................................y...................s.......l...............o...o...z...s...............l...........................................v...r.......o...{...........................t...w...........|...................~.......}...................|.......................................................................z.......................................................................................................................................................................}...........w...........................................................l...........................................s.......................h...........................................k.......t...y...u...r...{...v...................................t...................................}...}...........{...............................}...z...~.......x...................r.......................i...w.......................{...{.......~...............x...w...........................n...t...........v...................................}...................u.......w...s...o...}...q...|...}.......v.......................t...}...............~.......................................................................................}...................................~.......................................................}...........t...~...~...v...y...............x.......y...............y...........................................................................................y...............................q...q...}.......z.......................t...............................z...x.......w...........................................w...........................u...s...y...................................................x...s...s...............v...............x.......y.......x.......y...z...}.......................................~...................~.......................................................................................................................w.......................}...........y...........................................v.......x...r...................{...............}...........x.......y...........................o.......~...........................v.......................x...................w...........y...............x...........s...~...........z...........w...x...y...........................................x...z...............~...............................................w...........z...............u...........l.......s...........................x...................w...|...............|.......................r...........................}...........................................~...................x...n...............u.......u...........v...........y...}...~...|.......................................................................................................................................................................w...................}...x...}.......w.......y...........z...}...........{...............................s...}...................................................................~.......y...k...z.......n...r...{...............w.......}...........|...............s...w...{...{...........................y...............................................................................w...........................................}...b...w.......x.......................s.......u...y...y.......................u.......~...................{...........................................................................m.......................................}...l...........z...................~...........y.......................~...{...~.......................................................}...s.......................................|...........|...................................................................................................w...............z...........................x...........|...z...................t...............}...z.......p.......}.......}...{...................................~...............................................................................~.......................................z...|.......................z.......................................................................................o.......................x...................s...........o...............x...................n...z.......|...|.......y...........................................................................~...............................q...w...x...w...{.......................................{.......z...............}.......r...t...o...............................................................}...w...z...............~...|.......................}...................~...........................................................................v...........................z...u.......q...y...........z...}...........................t...x...s...............................z.......}...........................................................................................................x.......n.......................................z...q...........................................k...r.......z.......w...r.......s...........................................u.......y.......................y...|...y...................................y...............................................................z...................................q...........................p.......v...................................{...m...................f...........q...u.......~.......................................v...............................{...................................l...........y.......y.......................z...............................u...y...........................................................................................................................................................................................................w...z...........~.......g...|.......q...|.......w...~...y...................................................................................................................................o...e...i...k...s...w...{...y...r.......................v...............................................................................................q.......d...|...r...s...........................{...........t...x...........{...........z.......w...{...............{...............................................r.......x.......................................p...z.......................u...w...................................}...|...........................z.......................................................................................................................................x...................................................s.......................y...........j.......l.......................................s.......................j...................................k...p...............|...................w...................j...............m...r...w...p.......x...s.......................................y...............................................|...x.......}...............|...............{.......................u...{...........................................z...............................................~...............................................}.......................................~...................v.......................................w...............................z...............z...~...y.......................................................{...........}.......{...|.......................|...............~...~...~...........|...............................................}...........................v...........................{...........v...y.......~.......................r...............................}.......................................................y.......................................................................|.......|...............................................................|...w.......z.......................m...u...}...........x...z.......t...|.......|...........................~...~...............z...........................................u...|...}.......~...i...z.......w...................q...............................................~.......z...................................v...........k.......|.......}.......................r...p.......}...........................}...w.......{.......................}.......................................|...........|...w...|...~...y...........................}...........................................................~...........~...........~.......................w...........y...}...............x...z...........................u.......x...{.......|.......x...~...................................|...{.......}...........................................................................|...........m...........................~...{.......u.......|...........................................|...v...i...s.......t...|...|.......{...y...x...............}.......z...........................................................................................................................................................................n...............................z...............|...............z...~...t...................................k...........o...................................................................l...o.......r.......q...................z...........}.....................

Discussion

  • bebopfreak
    bebopfreak
    2011-01-11

    In order to make seeking work, I changed two functions - see attachment. I don't know what the modifications might break.

    There are more areas, where the library could be improved - but the whole
    project doesn't seem to be extremely vital.

    - some status code handling is broken
    - memory overflows aren't handled (annoying with Android phones)
    - no timeout management - therefore even device detection doesn't work in some environments
    - some null pointer, where you don't expect them
    - support for devices that are implemented incorrectly
    - ...

    -----------------------------------------------
    // in http/HTTPPacket.java

    public long[] getContentRange()
    {
    long range[] = new long[3];
    range[0] = range[1] = range[2] = 0;
    if (hasContentRange() == false)
    return range;
    String rangeLine = getHeaderValue(HTTP.CONTENT_RANGE);
    // Thanks for Brent Hills (10/20/04)
    if (rangeLine.length() <= 0)
    rangeLine = getHeaderValue(HTTP.RANGE);
    if (rangeLine.length() <= 0)
    return range;
    // Thanks for Brent Hills (10/20/04)
    StringTokenizer strToken = new StringTokenizer(rangeLine, " =/-");
    // Skip bytes
    if (strToken.hasMoreTokens() == false)
    return range;
    String bytesStr = strToken.nextToken();
    // Get first-byte-pos
    if (strToken.hasMoreTokens() == false)
    return range;
    String firstPosStr = strToken.nextToken();
    try {
    range[0] = Long.parseLong(firstPosStr);
    }
    catch (NumberFormatException e) {};
    if (strToken.hasMoreTokens() == false)
    return range;
    String lastPosStr = strToken.nextToken();
    try {
    range[1] = Long.parseLong(lastPosStr);
    }
    catch (NumberFormatException e) {};
    if (strToken.hasMoreTokens() == false)
    return range;
    String lengthStr = strToken.nextToken();
    try {
    range[2] = Long.parseLong(lengthStr);
    }
    catch (NumberFormatException e) {};
    return range;
    }

    // in httpHTTPRequest.java
    // didn't accept correct data before

    ////////////////////////////////////////////////
    // POST (Response)
    ////////////////////////////////////////////////

    public boolean post(HTTPResponse httpRes)
    {
    HTTPSocket httpSock = getSocket();
    long offset = 0;
    long length = httpRes.getContentLength();
    if (hasContentRange() == true) {
    // assume it's correct - these tests are bullshit
    // as content-length and total size are confused

    long firstPos = getContentRangeFirstPosition();
    /*
    long lastPos = getContentRangeLastPosition();

    // Thanks for Brent Hills (10/26/04)
    if (lastPos <= 0)
    lastPos = length - 1;
    if ((firstPos > length ) || (lastPos > length))
    return returnResponse(HTTPStatus.INVALID_RANGE);
    httpRes.setContentRange(firstPos, lastPos, length);
    */
    httpRes.setStatusCode(HTTPStatus.PARTIAL_CONTENT);

    offset = firstPos;
    // length = lastPos - firstPos + 1;
    }
    return httpSock.post(httpRes, offset, length, isHeadRequest());
    //httpSock.close();
    }

     
  • Thanks for your own effort on this web page. Kate take interest in making time for research and it's easy to see why. Many of us know all regarding the compelling way you deliver both interesting and useful solutions via this website and in addition boost participation from others on that area of interest so our own princess has always been understanding a lot. Take advantage of the remaining portion of the year. You are always performing a great job.
    <a href="http://www.itjacket.it" title="italy jacket">italy jacket</a>