Open
Conversation
This seems like the kind of thing that one should never want to do. Unless... you're dealing with a RESTful API that doesn't seem to understand URL parameters that contain numeric indices for the base array. [For example](smtech/canvaspest#3): Instructure Canvas is expecting URL parameters for arrays that do not include numerical indices: ``` http://canvas-instance.instructure.com/api/v1/courses/123/sections?include[]=students&include[]=enrollments ``` At the same time [`http_build_query()`](https://github.com/smtech/canvaspest/blob/9110d69f756ff49e8da687381eaee52a767c0389/CanvasPest.php#L108) is trying to build legal URL parameters, which require that at least the base URL be indexed, resulting in shenanigans like this: ``` http://canvas-instance.instructure.com/api/v1/courses/123/sections?include%5B0%5D=students&include%5B1%5D=enrollments ``` It appears, at least, that Canvas tolerates URL-encoded arrays, but not the indices, so a request like this would work, allowing the result of `http_build_query()` to be post-processed [as described here](http://php.net/manual/en/function.http-build-query.php#111819): ``` http://canvas-instance.instructure.com/api/v1/courses/123/sections?include%5B%5D=students&include%5B%5D=enrollments ```
battis
pushed a commit
to battis/pest
that referenced
this pull request
Aug 17, 2015
To allow the use of this repository without conflicts until/unless [the pull request](educoder#66) is merged into the main repository.
799f7c8 to
0fe1348
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This seems like the kind of thing that one should never want to do. Unless... you're dealing with a RESTful API that doesn't seem to understand URL parameters that contain numeric indices for the base array. For example:
Instructure Canvas is expecting URL parameters for arrays that do not include numerical indices:
At the same time
http_build_query()is trying to build legal URL parameters, which require that at least the base URL be indexed, resulting in shenanigans like this:Adding in an override-able
Pest::http_build_query()method allows for child classes to make necessary tweaks to the URL parameters before sending them to the API. For example: