Code Monkey home page Code Monkey logo

http-range's Introduction

ramsey/http-range

A PHP library for parsing and handling HTTP range requests.

Source Code Download Package PHP Programming Language Read License Build Status Codecov Code Coverage Psalm Type Coverage

About

ramsey/http-range is a PHP library for parsing and handling HTTP range requests.

This project adheres to a code of conduct. By participating in this project and its community, you are expected to uphold this code.

Installation

Install this package as a dependency using Composer.

composer require ramsey/http-range

Usage

Examples of how to use this library may be found in the Wiki pages.

Contributing

Contributions are welcome! To contribute, please familiarize yourself with CONTRIBUTING.md.

Coordinated Disclosure

Keeping user information safe and secure is a top priority, and we welcome the contribution of external security researchers. If you believe you've found a security issue in software that is maintained in this repository, please read SECURITY.md for instructions on submitting a vulnerability report.

Copyright and License

The ramsey/http-range library is copyright © Ben Ramsey and licensed for use under the MIT License (MIT). Please see LICENSE for more information.

http-range's People

Contributors

mdeboer avatar orkhanahmadov avatar ramsey avatar staabm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

http-range's Issues

Space in Range header result in a ParseException

Hey Ramsey,

thanks for the great work. I used your range parser as base for a new PSR Handler & Middleware, that I will publish soon. With my tests, a found an issue in your parser.

Best regards,
Tim

Description

I got this ParseException "Unable to parse range: 210-250" if the header is "bytes=0-199, 210-250"

Steps to reproduce

Call your code with a Range header incl. multiple ranges separated by space: bytes=0-199, 210-250

Expected behavior

I would expect the same behavior as with this header bytes=0-199,210-250 (without space). The space is allowed in this context and should be trimmed/skipped in the parsing process.

Same docs:

Environment details

  • version of this package: dev-main
  • PHP version: 8.2.7
  • OS: current macOS

Consider matching array_slice behavior instead of NotSatisfiableException

What is your opinion of changing the behavior of parseRange to match the same behavior as array_slice instead of throwing NotSatisfiableExceptions?

Example 1:

parseRange('0-300', 0); // => Throws NotSatisfiableException
array_slice([], 0, 300); // => []

When the entity has a totalSize of 0 you have to know that fact before requesting the range to avoid throwing an error.

Example 2:

parseRange('2-5', 1); // => Throws NotSatisfiableException
array_slice([0], 2, 5); // => []

The current behavior certainly makes sense (why would you request a random out-of-range range?), but it seems like conforming to a known interface/behavior like array_slice has some value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.