# Injection error

**URL:** <https://discourse.mitmproxy.org/t/injection-error/794>\
**Category:** help\
**Created:** [January 15, 2018, 4:57am UTC](https://discourse.mitmproxy.org/t/injection-error/794 "2018-01-15T04:57:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tremmert](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@tremmert](https://discourse.mitmproxy.org/u/tremmert)\
**Post date:** [January 15, 2018, 4:57am UTC](https://discourse.mitmproxy.org/t/injection-error/794/1 "2018-01-15T04:57:03Z")

</div>

Hello,  
I am trying to test some proof of concept software that utilizes mitmproxy. It is attempting to inject some javascript code into the browser, but is generating the following error;

192.168.9.127:1734: clientconnect  
192.168.9.127:1735: clientconnect  
[http://192.168.9.111:8000/script.js](http://192.168.9.111:8000/script.js)  
Script error: Traceback (most recent call last):  
File “[injector.py](http://injector.py)”, line 13, in response  
print(flow.response.headers[“content-type”])  
File “/root/.local/lib/python3.6/site-packages/mitmproxy/types/multidict.py”, line 39, in getitem  
raise KeyError(key)  
KeyError: ‘content-type’

Thoughts?

---

<div class="post-metadata">

**Author:** ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)\
**Post date:** [January 15, 2018, 1:00pm UTC](https://discourse.mitmproxy.org/t/injection-error/794/2 "2018-01-15T13:00:04Z")

</div>

Hi @tremmert,

Your response does not have a Content-Type header, so `flow.response.headers[“content-type”]` fails with a KeyError. That’s similar to `x = {}; x["foo"]`. You need to either check for existence or use `.get`. 🙂
