HTTP 斷點續傳

作者: 溪水清澈
客戶端請求域: Range
格式如下例子: 第一個500字節(字節偏移量0-499,包括0和499):
    Range: bytes=0-499
第二個500字節(字節偏移量500-999,包括500和999):
    Range: bytes=500-999
最後500字節(字節偏移量9500-9999,包括9500和9999):
    Range: bytes=-500 或 bytes=9500-
僅僅第一個和最後一個字節(字節0和9999):
    Range: bytes=0-0,-1  
關於第二個500字節(字節偏移量500-999,包括500和999)的幾種合法但不規範的敘述:
    Range: bytes=500-600,601-999
    Range: bytes=500-700,601-999
    
服務器響應域: 
    Accept-Ranges: bytes
    Content-Range: bytes 0-499/1234

當客戶端攜帶Range時, 
apache會自動響應狀態206,
即使是由PHP動態輸出的內容, 
也會截取相應的數據, 返回給客戶端.
如果PHP想自己來處理輸出內容, 
需要設置 Content-Range, 
即類似 header( 'Content-Range: bytes 0-499/1234' ),
Content-Length 一般會由apache來自動設置.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章