[GH-ISSUE #263] One-too-many bytes returned when supplying a range header #55

Closed
opened 2026-03-03 12:07:51 +03:00 by kerem · 3 comments
Owner

Originally created by @gh2k on GitHub (Jun 3, 2020).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/263

I think this was introduced by #255 (cc @chowey)

When calling fake-gcs from my tests, I am receiving one more byte than expected. This was working in version 1.18.4.

For example, I have a range header that sets bytes=0-8 and it receives 10 bytes back...

        it('should be able to get back the first 9 bytes of the file', async function() {
          const options = {
            uri: fileUrl,
            headers: {
              Range: 'bytes=0-8'
            }
          }
          const res = await rp.get(options)
          expect(res.body).to.equal('hello wor')
        })

yields an error because the client receives hello worl.

Originally created by @gh2k on GitHub (Jun 3, 2020). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/263 I think this was introduced by #255 (cc @chowey) When calling fake-gcs from my tests, I am receiving one more byte than expected. This was working in version `1.18.4`. For example, I have a range header that sets `bytes=0-8` and it receives 10 bytes back... ```JavaScript it('should be able to get back the first 9 bytes of the file', async function() { const options = { uri: fileUrl, headers: { Range: 'bytes=0-8' } } const res = await rp.get(options) expect(res.body).to.equal('hello wor') }) ``` yields an error because the client receives `hello worl`.
kerem 2026-03-03 12:07:51 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@chowey commented on GitHub (Jun 3, 2020):

Strange. Do you have a complete test that I can see to reproduce this?

<!-- gh-comment-id:638483172 --> @chowey commented on GitHub (Jun 3, 2020): Strange. Do you have a complete test that I can see to reproduce this?
Author
Owner

@fsouza commented on GitHub (Jun 3, 2020):

Hey @gh2k, sorry for moving from bug to question, just trying to gather some info here: what is rp.get doing with the Range header? Is it forwarding it as is?

<!-- gh-comment-id:638495646 --> @fsouza commented on GitHub (Jun 3, 2020): Hey @gh2k, sorry for moving from bug to question, just trying to gather some info here: what is `rp.get` doing with the `Range` header? Is it forwarding it as is?
Author
Owner

@gh2k commented on GitHub (Jun 9, 2020):

Ah, sorry. I had clearly not had enough coffee when I posted that. That's a snippet of an acceptance test that talks to my wrapper, which had been erroneously incrementing end by 1, rather than the bit that talks to GCS. 🤦‍♂️

My implementation actually matched the buggy behaviour of fake-gcs-server and so the fix broke my tests. I'd assumed my app was doing the right thing, but I think it is indeed returning one too many bytes when given a range.

<!-- gh-comment-id:641136161 --> @gh2k commented on GitHub (Jun 9, 2020): Ah, sorry. I had clearly not had enough coffee when I posted that. That's a snippet of an acceptance test that talks to my wrapper, which had been erroneously incrementing `end` by 1, rather than the bit that talks to GCS. :man_facepalming: My implementation actually matched the buggy behaviour of `fake-gcs-server` and so the fix broke my tests. I'd assumed my app was doing the right thing, but I think it is indeed returning one too many bytes when given a range.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#55
No description provided.