# Http input return code

**URL:** <https://discuss.elastic.co/t/http-input-return-code/108722>\
**Category:** Logstash\
**Created:** [November 22, 2017, 1:42pm UTC](https://discuss.elastic.co/t/http-input-return-code/108722 "2017-11-22T13:42:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cvi](https://avatars.discourse-cdn.com/v4/letter/c/c37758/32.png) [@cvi](https://discuss.elastic.co/u/cvi)\
**Post date:** [November 22, 2017, 1:42pm UTC](https://discuss.elastic.co/t/http-input-return-code/108722/1 "2017-11-22T13:42:08Z")

</div>

Hi,

I am testing the http input plugin with logstash 5.6 and I didn't find a way to answer something else than "ok". For instance, could something in the logstash pipeline filter control what to send back (e.g. an error if the payload isn't a valid one).

I saw another discussion ([issue #48](https://github.com/logstash-plugins/logstash-input-http/issues/48)) on the Github http input plugin repository, but this was related to errors with the pipeline **output**. In my case, checking for validity could be done "immediately".

Thanks

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [November 22, 2017, 3:29pm UTC](https://discuss.elastic.co/t/http-input-return-code/108722/2 "2017-11-22T15:29:11Z")

</div>

I had a look at the code. The question you need to answer is "What/how will you decide what is valid and what is not valid?"

If the payload **should** be JSON and sometimes it is not then you can use the JSON codec - any invalid JSON will raise an error and the input will return a 500 http status reply.  
The only way to have anything other than 200 be returned is to have a codec that raises an error if the payload is not valid. So if you need more complex validation than an existing codec can provide then you need to create a own custom codec.

---

<div class="post-metadata">

**Author:** ![cvi](https://avatars.discourse-cdn.com/v4/letter/c/c37758/32.png) [@cvi](https://discuss.elastic.co/u/cvi)\
**Post date:** [November 22, 2017, 5:01pm UTC](https://discuss.elastic.co/t/http-input-return-code/108722/3 "2017-11-22T17:01:11Z")

</div>

Thanks for your answer.

Actually, what I am looking for is to use the request path to decode the payload with specific filters and decide where to output data to. If the request path isn't valid (not one I am expecting), or even, if the specific filters don't match, I would like to send an error back instead of "ok".

I will have to find other ways to report such errors back. Currently, I am storing such invalid data into a specific index, but I was looking for a way to send immediate feedback.

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [November 23, 2017, 1:27pm UTC](https://discuss.elastic.co/t/http-input-return-code/108722/4 "2017-11-23T13:27:07Z")

</div>

I understand your validation requirements.  
The http response will be sent to the client as soon as the event has been created and put in the internal queue - this means you will not be able to use Logstash filters to change the http response because by the time the filter operate on the event the http request/response is finished.

If by "filters" you mean validation check done in a custom codec then that is do-able.

**For this validation you will need a custom codec**

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 21, 2017, 1:27pm UTC](https://discuss.elastic.co/t/http-input-return-code/108722/5 "2017-12-21T13:27:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
