# Additional Headers in PUT Request

**URL:** <https://forum.robotframework.org/t/additional-headers-in-put-request/8162>\
**Category:** RequestsLibrary\
**Created:** [12 December 2024 20:26 UTC](https://forum.robotframework.org/t/additional-headers-in-put-request/8162 "2024-12-12T20:26:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomekWro](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@TomekWro](https://forum.robotframework.org/u/TomekWro)\
**Post date:** [12 December 2024 20:26 UTC](https://forum.robotframework.org/t/additional-headers-in-put-request/8162/1 "2024-12-12T20:26:43Z")

</div>

Hello,

I’m automating Api Requests with RequestsLibrary and noticed additional headers in logs when using PUT:

```
 headers={'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '51'} 

```

where i put only

```
 'Authorization': 'Bearer <TOKEN>', 'Content-Type': 'application/json', 

```

Is there a way to disable those headers?

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [13 December 2024 01:08 UTC](https://forum.robotframework.org/t/additional-headers-in-put-request/8162/2 "2024-12-13T01:08:29Z")

</div>

Hi Tomasz,

These are the default headers (they come from the underlying python requests module.

First thing I’d try is define the headers you don’t want with a value of `None`, with a bit of luck that will un-define them 🤞

I’ve never done it but if you use [PUT On Session](https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html#PUT%20On%20Session) you may be able to use [Update Session](https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html#Update%20Session) to remove them before the PUT.

If you are using [PUT](https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html#PUT), maybe not because the requests module creates a temporary session to make the PUT call, and that temporary session creates the default headers.

I found [this example](https://stackoverflow.com/questions/27043402/python-requests-remove-the-content-length-header-from-post) of removing the default headers in python for the requests module, so it’s possible in the underlying code, just not sure if there’s anything implemented in this library.

Hopefully some else can give you a better answer,

Dave.

---

<div class="post-metadata">

**Author:** ![robinmackaij](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/robinmackaij/32/126_2.png) [@robinmackaij](https://forum.robotframework.org/u/robinmackaij)\
**Post date:** [18 December 2024 19:47 UTC](https://forum.robotframework.org/t/additional-headers-in-put-request/8162/3 "2024-12-18T19:47:32Z")

</div>

What is the problem you’re running into? It’s typical for frameworks / libraries / browsers / etc. to inject headers. What issue are you trying to resolve?

---

<div class="post-metadata">

**Author:** ![rasjani](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@rasjani](https://forum.robotframework.org/u/rasjani)\
**Post date:** [19 December 2024 07:52 UTC](https://forum.robotframework.org/t/additional-headers-in-put-request/8162/4 "2024-12-19T07:52:01Z")

</div>

Some of those are _necessary_ for the backend endpoint to respond correctly to your api call.

- User-agent: not required
- Accept-Encoding: not required but indicates to the server _if_ it can compress the response to avoid sending the response in plain-text. This is not required but if client provides this, backend server can optimize the amount of data that actually gets transfered back to you as reply to your call.
- Connection: This typically indicates that client can re-use the same socket for consecutive requests and server now knows this. If used without keep-alive, every consecutive request you make against the same server will close the tcp socket and re-open it again if new request is done. This will slow down the overall performannce. So, at least adviced to use it.
- Accept: this tells the backend server what format the client accepts the response in. Might not be required and since this is wild-card “accept anything”, most likely not necessary. Most of the real-world scenarios use same value here as `Content-type`
- Content-Length: **required** but its presence depends on what http method are are using. Since you are putting a json, backend server needs to know the lenght of data you are sending and requests calculates that for you so that you do not need to do it manually.

So in general, all of those headers except user-agent do serve an actual purpose for your client and backend communicating and removing _all_ of them sounds like a bad idea.

---

<div class="post-metadata">

**Author:** ![TomekWro](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@TomekWro](https://forum.robotframework.org/u/TomekWro)\
**Post date:** [5 January 2025 10:02 UTC](https://forum.robotframework.org/t/additional-headers-in-put-request/8162/5 "2025-01-05T10:02:51Z")

</div>

Hello,

Thanks for help! 🙂

I was trying to test what will happen when i remove the headers, check behavior. Nothing to fancy.

Setting None helped for what i was trying to achieve.
