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

Improving tests and edge cases for URI and HTTP #8497

Merged
merged 34 commits into from
Dec 15, 2023

Conversation

radeusgd
Copy link
Member

@radeusgd radeusgd commented Dec 7, 2023

Pull Request Description

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@radeusgd radeusgd added the CI: No changelog needed Do not require a changelog entry for this PR. label Dec 7, 2023
@radeusgd radeusgd self-assigned this Dec 7, 2023
@radeusgd radeusgd linked an issue Dec 7, 2023 that may be closed by this pull request
@radeusgd radeusgd changed the base branch from develop to wip/radeusgd/8111-big-excel-fix December 7, 2023 18:12
@radeusgd
Copy link
Member Author

radeusgd commented Dec 7, 2023

I base this PR on top of #8403, because there I have started adding the Fetch_Spec tests extending the simple-httpbin and this PR is adding some further extensions to it - so to avoid conflicts I just developed on top of it. So, this PR should ideally be merged after #8403 gets merged.

@radeusgd radeusgd force-pushed the wip/radeusgd/8352-cloud-followup-1 branch from 8cd5c51 to 9a11fc7 Compare December 8, 2023 13:33
@radeusgd radeusgd force-pushed the wip/radeusgd/8352-cloud-followup-1 branch 2 times, most recently from 20966e9 to 3d6856b Compare December 14, 2023 12:58
Base automatically changed from wip/radeusgd/8111-big-excel-fix to develop December 15, 2023 00:02
@radeusgd radeusgd force-pushed the wip/radeusgd/8352-cloud-followup-1 branch from 3d6856b to f951403 Compare December 15, 2023 10:07
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not convinced adding 3rd party dependency to the std-base is a good idea.

"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion,
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided"
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion,
"org.apache.httpcomponents" % "httpclient" % httpComponentsVersion,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we adding dependency on an external library to std-base just be able to emit HTTP request? What's wrong with JDK only solution?

Copy link
Member Author

@radeusgd radeusgd Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are still using JDK's httpclient for the requests (see EnsoSecretHelper.java).

The functionality that was missing was the URIBuilder that allows us to build a set of query parameters and correctly encode them. The task is not trivial as it requires escaping of various control characters depending on context (sometimes = sometimes not, & etc.) as well as escaping non-standard Unicode symbols.

We had our own simple implementation but it was missing functionalities.

Instead of trying to understand the RFC 3986 and trying to carefully implement and test that we are doing everything according to the specification, I thought it will be far simpler to use an existing solution.

If that ever turns out to be problematic, we could roll our own - but it seems like an overkill if an existing solution exists.

Note that in subsequent PRs (#8544) I plan to extend using this functionality. The URIBuilder allows us to easily parse the existing query and modify it in any way we need, as well as it allows us to parse and modify the URI path and all the other components. The JDK provides only very limited funcionality for that (e.g. we don't get the parsing of the query arugments that we need to be able to manipulate them).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@JaroslavTulach JaroslavTulach Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is URLEncoder which has been good enough for all my purposes so far.

I continue to be convinced that

adding dependency on (another) external library to std-base

isn't good idea.

import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import org.apache.http.client.utils.URIBuilder;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is similar builder in the JDK as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it similar?

This is a HttpClient.Builder, I cannot see any capabilities for building an URI with it.

@radeusgd radeusgd added the CI: Ready to merge This PR is eligible for automatic merge label Dec 15, 2023
@mergify mergify bot merged commit 940b8f7 into develop Dec 15, 2023
32 checks passed
@mergify mergify bot deleted the wip/radeusgd/8352-cloud-followup-1 branch December 15, 2023 17:58
mergify bot pushed a commit that referenced this pull request Dec 20, 2023
- After [suggestion](#8497 (comment)) from @JaroslavTulach I have tried reimplementing the URL encoding using just `URLEncode` builtin util. I will see if this does not complicate other followup improvements, but most likely all should work so we should be able to get rid of the unnecessary bloat.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Follow on from the Enso Cloud API PR.
6 participants