Skip to content

Commit

Permalink
Adds workaround for hapi h2o2 proxy issue for DELETE REST calls that …
Browse files Browse the repository at this point in the history
…have bodies in developer mode (#87270)

## Summary

When you run Kibana in developer mode you have 3 random digits assigned to your URL and we proxy things through a [h2o2 proxy](https://github.com/hapijs/h2o2) to help the developers with development with regards to proxies

```ts
node --max-old-space-size=2048 scripts/kibana --dev
```

However when you try to send a body with the DELETE verb in the browser such as using the `security_solution` and try to delete a rule:
<img width="640" alt="Screen Shot 2021-01-04 at 8 06 15 PM" src="https://user-images.githubusercontent.com/1151048/103602057-53b92380-4ec8-11eb-972c-7e57317bccab.png">

You get an error toaster showing up who's content is "Bad Request":
<img width="457" alt="Screen Shot 2021-01-04 at 8 03 14 PM" src="https://user-images.githubusercontent.com/1151048/103601947-05a42000-4ec8-11eb-94d9-0ea834a20310.png">

The reason for this bug looks to be from our proxy usage of `h2o2` when we are in development mode where it removes `content-length` when you send a body with a `DELETE`. I created a bug and workaround for the `h2o2` project directly:
hapijs/h2o2#124

This fix here is the workaround applied to Kibana. With this workaround applied there should be no more error toasters for developers.

Additional fixes/improvements are:
* I ported the unit tests from `src/core/server/http/http_server.test.ts` to `src/core/server/http/base_path_proxy_server.test.ts` since the `base_path_proxy_server` did not have any unit tests. I also added additional unit tests to cover the specific use cases that are in `base_path_proxy_server`
* I fixed the placement of some tests from `src/core/server/http/http_server.test.ts` where there were a few that were under the wrong describe block and I changed a few `it` -> `test` as it looks like that file should be consistent with `test` instead of odd mixture of `it`.

### Checklist

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
  • Loading branch information
FrankHassanabad authored Jan 11, 2021
1 parent 379f9c9 commit 2658855
Show file tree
Hide file tree
Showing 3 changed files with 1,130 additions and 68 deletions.
Loading

0 comments on commit 2658855

Please sign in to comment.