1

My CURL command:-

curl -X POST \
  http://localhost:8000/sendData/ \
  -H 'authorization: Token b67d31c42d98b3c97b28c737629dca63ef5043fc' \
  -H 'cache-control: no-cache' \
  -H 'client_cdata: virat' \
  -H 'clientdata: sachin' \
  -H 'content-type: multipart/form-data;' \
  -H 'postman-token: ed70d17c-ecf6-66c7-619e-85eac7d62803' \
  -F purchasID=23124212 \
  -F purchaserAmount=4320'

I tried to get Header Data

using request.META['HTTP_CLIENTDATA']

I got the value sachin same as when i try to get request.META['HTTP_CLIENT_CDATA'] it not working, It's showing the *** KeyError error.

What is the correct format to get Header value when header name contain _?

I can't change header data, Because of this API is called by another domain(It result provided by another site or server), I'm creating API end points.

Thanks in advance.

Mr Singh
  • 3,936
  • 5
  • 41
  • 60

1 Answers1

0

Working on the assumption that you're probably using either Nginx or Apache as a reverse proxy, headers containing underscores are dropped by these servers to avoid problems when mapping such headers to CGI variables.

If you need to support underscores - which it sounds as though you do, because they're coming from a third party - then you have to enable support.

For Nginx (link)

underscores_in_headers on;

For Apache (link)

SetEnvIfNoCase ^client.cdata$ ^(.*)$ fix_client_cdata=$1
RequestHeader set client-cdata %{fix_client_cdata}e env=fix_client_cdata
Will Keeling
  • 22,055
  • 4
  • 51
  • 61