Opened 4 months ago

Closed 4 months ago

#35310 closed Cleanup/optimization (wontfix)

Optimize automatic JSON encoding of data in test client

Reported by: Kasun Herath Owned by: Kasun Herath
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Test client post, put, patch and delete methods automatically encode request data to JSON if content_type parameter is set to application/data.

Example, data=data, content_type="application/json")

Would automatically encode data as JSON.

We could also check the headers for content_type header and do the automatic encoding to be consistent.

example, data=data, headers={"content_type": "application/json"})

Can automatically encode data into JSON using the same mechanism.

Change History (1)

comment:1 by Natalia Bidart, 4 months ago

Resolution: wontfix
Status: assignedclosed

Hello Kasun Herath, thank you for your report. Could you please expand a little bit on your use case? Why do you need to pass the content-type as a header and not as param?

If you see the test client POST docs, the content type should be passed as a separated parameter. Following the code, if both the content_type param and the headers param with a content_type key is given, the latter overrides the first.

I'll close the ticket for now because JSON encoding is documented to occur when the content_type param is passed with a specific value, but we'd need more information to understand the specific use case to make further decisions.

Note: See TracTickets for help on using tickets.
Back to Top