Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy: allow option to record request body as part of output config #628

Open
nickperkins opened this issue Sep 20, 2024 · 3 comments
Open
Assignees

Comments

@nickperkins
Copy link

We're trying to use imposter to record responses for some POST requests. The responses change depending on the body data being sent, but imposter doesn't record that information in the config of the recording.

It would be helpful if imposter could store the request body when writing out the config so that you can then have body matching for the requests.

@outofcoffee
Copy link
Owner

Hi @nickperkins, thank you for raising this. This is a great idea!

Would you be in a position to submit a pull request to the imposter-cli project?

@outofcoffee
Copy link
Owner

Added support in the engine for matching on arbitrary request bodies (not just JSON and XML) in v4.1.0, which is a useful step towards this.

Next step would be to capture request bodies in the CLI and use the new raw request body matcher in the config it writes.

@outofcoffee
Copy link
Owner

outofcoffee commented Nov 20, 2024

Hi @nickperkins, this is now supported from CLI version v0.45.0.

Example

Usage:

imposter  proxy http://example.com --capture-request-body --capture-request-headers --output-dir=/tmp/proxy

Test:

curl http://localhost:8080/foo -H 'bar:baz' --data 'foo' -H 'content-type: text/plain' --raw -v

Output:

plugin: rest
resources:
- method: POST
  path: /foo
  requestBody:
    operator: EqualTo
    value: foo
  requestHeaders:
    Accept: '*/*'
    Bar: baz
    Content-Type: text/plain
    User-Agent: curl/8.7.1
  response:
    headers:
      Content-Type: text/html; charset=UTF-8
    statusCode: 405

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants