Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getOffsetFromResponse isn't behaving quite right #46

Closed
JohnHayford opened this issue Jul 10, 2019 · 1 comment
Closed

getOffsetFromResponse isn't behaving quite right #46

JohnHayford opened this issue Jul 10, 2019 · 1 comment

Comments

@JohnHayford
Copy link

JohnHayford commented Jul 10, 2019

in uploaderx.ts, getOffsetFromResponse doesn't seem to be behaving quite right for the following use cases.
Missing Range: this should be allowed, using the same Google Doc upload reference (https://developers.google.com/drive/api/v3/manage-uploads#resume-upload) that you are using. This should tell the service that no content has been received and to start at byte 0.

"Range: bytes=0-1" : This will get matched as "-1" and will send from byte 0. There's not really a standard on using the Range header on a response, so not sure of what the right answer is. Possible solution would be looking for two dashes when matching "-1", ie, "-1--1" for no content. /(--1|\d+)$/g
Also looking for just "-1", like "Range: bytes=-1" could work.

https://github.com/kukhariev/ngx-uploadx/blob/master/src/uploadx/src/uploaderx.ts

kukhariev added a commit that referenced this issue Jul 15, 2019
kukhariev added a commit that referenced this issue Jul 16, 2019
@kukhariev
Copy link
Owner

I think it'll work 🛴

describe('getRangeEnd', () => {
it('invalid ranges', () => {
expect(getRangeEnd(undefined)).toEqual(-1);
expect(getRangeEnd('')).toEqual(-1);
expect(getRangeEnd('-invalid-')).toEqual(-1);
expect(getRangeEnd('Range: bytes=-1')).toEqual(-1);
expect(getRangeEnd('Range: bytes=-5')).toEqual(-1);
expect(getRangeEnd('Range: bytes=0--5')).toEqual(-1);
expect(getRangeEnd('Range: bytes=0--1')).toEqual(-1);
});
it('valid ', () => {
expect(getRangeEnd('Range: bytes=0-1')).toEqual(1);
expect(getRangeEnd('Range: bytes=0-0')).toEqual(0);
expect(getRangeEnd('Range: bytes=0-100')).toEqual(100);
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants