nighthawk icon indicating copy to clipboard operation
nighthawk copied to clipboard

Add more echo responders to test server filter ResponseOptions.

Open efimki opened this issue 5 years ago • 2 comments

This is a follow-up to comments on #338 which has added echo_request_headers to the test server filter ResponseOptions.

I'd like to add more response options that I think might be useful:

  • echo_request_metadata - include the dump of request metadata in the response body
  • echo_request_body - include the body of POST request in the response body
  • status_code - set http status code to arbitrary value, like 204 or 302

@htuch has suggested that we might want to eventually have a more structured body. E.g. make it a proto defined JSON format or something like that.

I think that makes sense, and I'd like to have more input.

  • Should echo response be included into response body or special response headers? I think that including response in headers are nice because they could be stripped automatically AND are easily parsed. E.g. x-echo-request-headers: { some_headers_dump }.

  • What format do we want structured response to use? Arbitrary JSON? Some specifically defined proto? Something else?

Any other ideas / suggestions?

efimki avatar Jun 09 '20 18:06 efimki

Re: format, in Envoy (and basically NH), we tend to use proto3 to define formats canonically. You can then use Proto3 <-> JSON transform methods in the proto libs.

htuch avatar Jun 09 '20 23:06 htuch

I'm not sure if it would be the right thing to re-use it, but it might be worth taking a look at RequestSpecifier over at https://github.com/envoyproxy/nighthawk/blob/master/api/request_source/service.proto

Also, to float an idea, maybe another nice feature could be to direct the test server to yield x chunks of transfer-encoded data, with configurable size and inter-chunk timings. (Note -- I do not have a clear idea about what it would take to pull this off)

oschaaf avatar Jun 10 '20 11:06 oschaaf