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

“range=-n” support may add #3

Open
xfap opened this issue Mar 11, 2019 · 2 comments
Open

“range=-n” support may add #3

xfap opened this issue Mar 11, 2019 · 2 comments

Comments

@xfap
Copy link

xfap commented Mar 11, 2019

> for last n bytes

if (StringUtils.isEmpty(bounds[0])) {//
				nums = Long.valueOf(bounds[1]);
				from = (size > nums) ? size - nums : 0;
				to = size - 1;
			} else {
				from = Long.valueOf(bounds[0]);
				to = (bounds.length == 2 ? Long.valueOf(bounds[1]) : 0);
			}

> check for range byets could be added too, if the arg is wrong, the range list should be empty but no parse exception.

private boolean check(String pointerStr) {
		//System.out.println(pointerStr);
		if(pointerStr.startsWith("bytes=")&&pointerStr.split("=").length==2) {
			String value=pointerStr.split("=")[1];
				for(String sp:value.split(",")) {
					if(!sp.matches("(^-\\d+)|(^\\d+(?:-?|-\\d*))"))
						return false;
				}
		}else {
			return false;
		}
		return true;
	}
@heruan
Copy link
Owner

heruan commented Mar 11, 2019

Thank you for reporting this! I'll consider to add this in the next release (but there is not ETA for it yet).

@namedgraph
Copy link

@heruan has this been merged?

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

3 participants