Anvil.http.request may mess up headers if json=True [minor bug]

What I’m trying to do:
Investigating Anvil.http.request throws info away on http_422 and http_400

What I’ve done:
I took a peek in anvil-runtime/downlink/python/anvil/http.py and anvil-runtime/client/js/modules/http.js

The Python implementation of anvil.http.request can mess-up HTTP headers when json=True.
Reason is that HTTP header keys are case insensitive. So “content-type” and “Content-Type” are the same header.
The implementations:

  • Python: headers["content-type"] = "application/json"
  • JS: kwargs["headers"]["Content-Type"] = "application/json"

both ignore the case of the header key and may case a duplicate if the user already had specified content-type. However, the JS code is only executed when the user didn’t already specify content-type. And here the test is done case-insensitive. But such test lacks in the Python implementation of anvil.http.request()