# Cowboy + Hound + PhantomJS problems

**URL:** <https://forum.elixirforum.com/t/cowboy-hound-phantomjs-problems/19031>\
**Category:** Questions\
**Tags:** hound, cowboy, phantomjs\
**Created:** [December 29, 2018, 12:59pm UTC](https://forum.elixirforum.com/t/cowboy-hound-phantomjs-problems/19031 "2018-12-29T12:59:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qqwy](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qqwy/32/1349_2.png) [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Post date:** [December 29, 2018, 12:59pm UTC](https://forum.elixirforum.com/t/cowboy-hound-phantomjs-problems/19031/1 "2018-12-29T12:59:48Z")

</div>

I am working on setting up integration testing of our Phoenix-application using Hound. I encountered a very strange error, which is that when using PhantomJS as Hound browser driver, Cowboy will reject all incoming connection with an ‘error 400’.

Searching the internet I found out that [other people had a similar problem](https://github.com/ninenines/cowboy/issues/1294) with Cowboy as well: PhantomJS does not by default seem to add a `Host:`-header to the requests it does, which is against the HTTP spec and rejected by Cowboy (as well as happily accepted by most other webservers).

Switching to Selenium+Firefox instead of PhantomJS and everything works fine.  
So just a heads-up that this issue exists. I’m not sure how this could/should be resolved; what would be the best approach?

- Ask the developers of PhantomJS to alter its default settings so it follows the spec.
- Update Hound so it requests PhantomJS to set a `Host:`-header when connecting.
- Update Hound so it has the possibility to add custom HTTP headers from your own code.
- Ask the people behind Cowboy to create a way to accept requests with missing `Host:`-headers.

---

<div class="post-metadata">

**Author:** ![idi527](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/i/85e7bf/32.png) [@idi527](https://forum.elixirforum.com/u/idi527)\
**Post date:** [December 29, 2018, 1:07pm UTC](https://forum.elixirforum.com/t/cowboy-hound-phantomjs-problems/19031/2 "2018-12-29T13:07:41Z")

</div>

> [@Qqwy](#):
>
> Ask the developers of PhantomJS to alter its default settings so it follows the spec.

I think it might be easier to switch to chrome. I’m not sure if there’s anyone left to develop phantomjs further at this point: [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/phantomjs/9aI5d-LDuNE).

I mostly use [GitHub - puppeteer/puppeteer: JavaScript API for Chrome and Firefox · GitHub](https://github.com/GoogleChrome/puppeteer) for “end-to-end” tests.

---

<div class="post-metadata">

**Author:** ![Qqwy](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qqwy/32/1349_2.png) [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Post date:** [December 29, 2018, 1:52pm UTC](https://forum.elixirforum.com/t/cowboy-hound-phantomjs-problems/19031/3 "2018-12-29T13:52:43Z")

</div>

> [@idi527](#):
>
> I think it might be easier to switch to chrome

At first I switched to Selenium + Firefox, but lo and behold, `Hound` crashes whenever you try to run a `find_element` because it cannot understand the current format that is returned by the webdriven Firefox.

The Selenium+Chrome driver still works fine, though.

@idi527 Do you use puppeteer instead of Hound, or somehow from within Hound? I’d like to keep all my tests in Elixir-land, because the existing tests are, and because most of the stuff is server-side related anyway.

---

<div class="post-metadata">

**Author:** ![idi527](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/i/85e7bf/32.png) [@idi527](https://forum.elixirforum.com/u/idi527)\
**Post date:** [December 29, 2018, 2:07pm UTC](https://forum.elixirforum.com/t/cowboy-hound-phantomjs-problems/19031/4 "2018-12-29T14:07:25Z")

</div>

> Do you use puppeteer instead of Hound, or somehow from within Hound?

Yes, I got frustrated with `Hound` and `Wallaby` at the time, and just wrote these tests in js, which was surprisingly easy.
