Codeception / Codeception/lib-innerbrowser

[Lib/InnerBrowser] Send raw content in post body

Aperta
#61 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
PHP
Stelle
87
Fork
20
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

#### 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?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia in src/Codeception/Lib/InnerBrowser.php intorno alla riga 189 e verifica come sendAjaxPostRequest valida e formatta il suo secondo parametro. Confronta il comportamento documentato degli array con gli esempi di JSON non elaborato e testo semplice; il lavoro è completato quando i chiamanti possono inviare contenuto non elaborato senza che venga convertito da http_build_query.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.