Azure / azure-functions-java-library

Contains annotations for writing Azure Functions in Java
MIT License
43 stars 43 forks source link

Request Headers not being injected into HttpRequestMessage #87

Closed zhughes3 closed 5 years ago

zhughes3 commented 5 years ago

I have setup an Azure Function using the Java runtime locally and have published it to Azure. Everything has been fairly smooth so far with one caveat. Inside my function body, I need to interact with the HTTP Request Headers. This is an easy enough task - just make a call to request.getHeaders() which should return a Map<String, String>. Then I can just interact with the map in the regular way, e.g. calling .get(), passing it the name of the header I want.

However, any call to get a header from the Map returns null.

Here is my curl request to my function with the headers I expect to the see in the request.

*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 7071 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 7071 (#0)
> GET /api/HttpTrigger-Java?company=boom&location=ok HTTP/1.1
> Host: localhost:7071
> User-Agent: curl/7.54.0
> Accept: */*
> CustomHeader: boom

And here is a picture showing the output of the getHeaders() call. Screen Shot 2019-03-12 at 2 00 15 PM (2)

Can anybody offer some recommendations? Is there anything I have to do to make the request headers be injected into the getHeaders() variable?

zhughes3 commented 5 years ago

Realized that all header keys get transformed to lowercase in the backend. Closing this.