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

Issue with basePath encoding in result uri #840

Open
RocketRaccoon opened this issue Mar 29, 2017 · 3 comments
Open

Issue with basePath encoding in result uri #840

RocketRaccoon opened this issue Mar 29, 2017 · 3 comments

Comments

@RocketRaccoon
Copy link
Contributor

Hi,

Have got an issue with latest version 3.0.2
We used some custom filter which replaced %7E back to ~ in result url.
It was done via manipulating FilterContext and replacing originalPath and substitutedPath.
In latest version that trick does not work.
So I'm expecting:
Logged in console http://localhost:8080/restapi/v1.0/acc/~/ext/asdhdj,123fhfjhs,null,"%@*:!"
Sent to server http://localhost:8080/restapi/v1.0/acc/~/ext/asdhdj%2C123fhfjhs%2Cnull%2C%22%25%40*%3A%21%22"

Actual sent to server:
http://localhost:8080/restapi/v1.0/acc/%7E/ext/asdhdj%2C123fhfjhs%2Cnull%2C%22%25%40*%3A%21%22"

Could you please giva an advice how to solve it in better way?

@RocketRaccoon RocketRaccoon changed the title Issue with encoding basePath Issue with basePath encoding in result uri Mar 29, 2017
@johanhaleby
Copy link
Collaborator

Hmm one idea would be to disable URL encoding and perform it yourself in a filter. Thus you should be able to control exactly how to deal with certain characters.

@RocketRaccoon
Copy link
Contributor Author

RocketRaccoon commented Mar 30, 2017

Have tried but got issue with method CustomRequestSpecificationImpl#generateRequestUriForLogging
So current solution is to disable encoding for all CustomRequestSpecificationImpl#partiallyApplyPathParams and logging filters and added

 URL url = new URL(targetUri)
        URI uriFromUrl = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef())
        targetUri = uriFromUrl.toASCIIString()

to generateRequestUriForLogging() and

  URL url = new URL(baseUri + targetPath)
            URI uriFromUrl = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef())
uri.path = uriFromUrl.getRawPath()

to sendHttpRequest()

@RocketRaccoon
Copy link
Contributor Author

@johanhaleby I could provide pull request if you guide me how to fix it in a better way

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