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

KTOR-326 Allow to set followRedirect property for js client engine #3053

Merged
merged 1 commit into from Jun 17, 2022

Conversation

e5l
Copy link
Member

@e5l e5l commented Jun 13, 2022

Fix KTOR-326

@e5l e5l requested a review from rsinukov June 13, 2022 14:18
@e5l e5l self-assigned this Jun 13, 2022
@@ -31,13 +33,14 @@ internal class JsClientEngine(override val config: HttpClientEngineConfig) : Htt
@OptIn(InternalAPI::class)
override suspend fun execute(data: HttpRequestData): HttpResponseData {
val callContext = callContext()
val clientConfig = data.attributes[CLIENT_CONFIG]
Copy link
Contributor

Choose a reason for hiding this comment

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

why pass it through data? there is a property config in class

Copy link
Member Author

Choose a reason for hiding this comment

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

cause we need client config, not engine

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. Let's create a ticket to pass client config in client factory HttpClientEngineFactory.create method in 3.0.0 for a proper fix.

@@ -129,7 +134,7 @@ private fun Event.asString(): String = buildString {
append(JSON.stringify(this@asString, arrayOf("message", "target", "type", "isTrusted")))
}

private fun io.ktor.client.fetch.Headers.mapToKtor(): Headers = buildHeaders {
private fun org.w3c.fetch.Headers.mapToKtor(): Headers = buildHeaders {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this works on nodeJS? See also #2592

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, we replace some types, and the actual implementation stays the same.

Copy link
Member Author

Choose a reason for hiding this comment

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

The tests are also fine

Copy link
Contributor

Choose a reason for hiding this comment

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

Unit tests? AFAIK they does not work with nodeJS production, at least 1 year ago, which results into the same problem at runtime: #2385 so you needed to create a test project and use the artifact.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will try to set up a sample

Copy link
Member Author

Choose a reason for hiding this comment

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

Made a sample for node: it works

@e5l e5l requested a review from rsinukov June 14, 2022 06:32
Copy link
Contributor

@rsinukov rsinukov left a comment

Choose a reason for hiding this comment

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

LGTM, but please check sample with node

@@ -31,13 +33,14 @@ internal class JsClientEngine(override val config: HttpClientEngineConfig) : Htt
@OptIn(InternalAPI::class)
override suspend fun execute(data: HttpRequestData): HttpResponseData {
val callContext = callContext()
val clientConfig = data.attributes[CLIENT_CONFIG]
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. Let's create a ticket to pass client config in client factory HttpClientEngineFactory.create method in 3.0.0 for a proper fix.

@e5l e5l merged commit 3aded41 into main Jun 17, 2022
@e5l e5l deleted the e5l/js-redirect branch June 17, 2022 07:02
@e5l
Copy link
Member Author

e5l commented Jun 17, 2022

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

Successfully merging this pull request may close these issues.

None yet

3 participants