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

curl customiser #2

Closed
blacky0x0 opened this issue Sep 29, 2016 · 8 comments
Closed

curl customiser #2

blacky0x0 opened this issue Sep 29, 2016 · 8 comments

Comments

@blacky0x0
Copy link

What is about customising?
Enable or disable parameters or headers like:

  • -i
  • --insecure
  • --verbose
  • --compressed
  • Host
  • Connection
  • User-Agent

It will make curl query very short and simple.

@dzieciou
Copy link
Owner

Interesting idea. Can you provide a pull request with an implementation of your idea?

@blacky0x0
Copy link
Author

Well I don't know how to implement it carefully. I wrote my own FormattedCurlLoggingInterceptor#process and delete all required strings by pattern with replaceFirst. It's very dirty solution.

@dzieciou
Copy link
Owner

dzieciou commented Sep 1, 2017

@blacky0x0 I know it's been a year since you requested this feature. I have just completed it.

Does it do what you wanted?

There's README.md file in feature/2 branch that explains how to use it.

@blacky0x0
Copy link
Author

Sure, I'll check it and write feedback

@blacky0x0
Copy link
Author

blacky0x0 commented Sep 4, 2017

The Authorization, Content-Type headers and data-binary are on the place.

Yes, that's what I wanted before. It's tidy and looks great.
But I've tested my app and discovered that without User-Agent header the system changes own behaviour because it relies on it.
More precisely, it asks for pin-code.

I want to configure Http2Curl.HEADERS_TO_SKIP_IN_SHORT_FORM to be able to add / remove items.
@dzieciou Can it be configured? What do you think about it?

@dzieciou
Copy link
Owner

dzieciou commented Sep 4, 2017

@blacky0x0

The idea behind the library is to enable reproducing a certain case that occured. As you have shown with your User-Agent example, by removing certain headers curl-logger would generate curl that generates different requests that trigger in different system responses. That would undermine the original purpose of the library.

On the other head, I understand, sometimes we need to modify generated curl to test different variations of the same case. And doing this manually might be tedious. Adding possibility to decide which header to include in curl expression is an easy change but it opens a door for other similar feature requests to remove "--binary-data" parameter, replace "--insecure" parameter with its shorter form "-k", etc.

Therefore, I think modifying curl expression should be an option but it should be done by the user of the library more explicitly, so s/he is aware what exactly is modified. Practically, I am thinking of giving more control to the users on constructing curl:

RestAssuredConfig config = new CurlLoggingRestAssuredConfigBuilder()
  .modifyCurl(curl -> curl.removeHeader("Host").addParameter("-k"))
  .build();

This would require significant change in Http2Curl architecture but it would solve your problem, right?

dzieciou added a commit that referenced this issue Sep 4, 2017
…parameters and modify a curl command before printing it.
@dzieciou
Copy link
Owner

dzieciou commented Sep 4, 2017

Updated. Let me know if it does what you wanted.

@blacky0x0
Copy link
Author

Exactly!
To be precise I log all requests, responses and curl-commands.
I want to skip all keys and headers which have no matter in specific case.
It will simplify readability of curl-commands.

@dzieciou dzieciou closed this as completed Sep 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants