Codeception / Codeception/lib-innerbrowser
[Lib/InnerBrowser] Send raw content in post body
- Vorherrschende Sprache
- PHP
- Sterne
- 87
- Forks
- 20
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
#### What are you trying to achieve?
I am trying to call `sendAjaxPostRequest` and I would like to pass raw, unformatted parameters to the server.
For example
```php
$I->sendAjaxPostRequest('/some-endpoint', '{"foo": "bar"}');
// or even
$I->sendAjaxPostRequest('/some-endpoint', 'hello, how do you do?')
```
#### What do you get instead?
I get an error saying that the second parameter of sendAjaxPostRequest must be of type array. This array then gets converted using http_build_query and there is no way to pass raw data. See https://github.com/Codeception/Codeception/blob/3.1/src/Codeception/Lib/InnerBrowser.php#L189
When passing an array, the array always gets converted to http query params format of `foo=bar&example=codeception`
I think an alternative approach could be to use REST Module, which I think can accept raw content (or at least properly json_encode body).
Is there something I am missing? How would you suggest to test this endpoint?
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne in src/Codeception/Lib/InnerBrowser.php etwa bei Zeile 189 und untersuche, wie sendAjaxPostRequest seinen zweiten Parameter validiert und formatiert. Vergleiche das dokumentierte Array-Verhalten mit den Beispielen für rohes JSON und Plaintext; als erledigt gilt die Änderung, wenn Aufrufer rohe Inhalte senden können, ohne dass diese durch http_build_query konvertiert werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- api
- Issue-Typ
- Feature
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100