gyselroth / balloon

High performance, feature rich document management system written for the cloud
GNU General Public License v3.0
18 stars 7 forks source link

Fetch content with an empty Range header results in error 500 Undefined offset: 1 #434

Closed raffis closed 4 years ago

raffis commented 4 years ago

Describe the bug

method: GET
uri: /api/v2/nodes/5e14a6d6831b966e4d1be55f/content?encode=base64
headers: 
    Range: 
    User-Agent: Dredd/12.2.0 (Linux 4.15.0-20-generic; x64)
    Authorization:  Basic YWRtaW46YWRtaW4=

body: 

expected: 
headers: 

statusCode: 200
bodySchema: {"type":"string"}

actual: 
statusCode: 500
headers: 
    accept-ranges: bytes
    content-disposition: inline; filename*=UTF-8''foo
    content-length: 67
    content-type: application/json; charset=utf-8
    date: Tue, 07 Jan 2020 15:42:20 GMT
    etag: "96948aad3fcae80c08a35c9b5958cd89"
    server: nginx/1.17.6
    x-powered-by: PHP/7.3.12
    connection: close

bodyEncoding: utf-8
body: 
{
  "error": "ErrorException",
  "message": "Undefined offset: 1",
  "code": 0
}

To Reproduce

  1. Create file
  2. curl -u admin:admin http://localhost:8084/api/v2/nodes/{id}/content?encode=base64 -H "Range: ''"

Expected behavior

No such error. Empty range header should be equal as no range header.

Environment