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

Supplement modular azure core basic test case #2236

Merged
merged 11 commits into from
Mar 18, 2024

Conversation

v-jiaodi
Copy link
Member

@v-jiaodi v-jiaodi commented Jan 23, 2024

Fixes #2207

@qiaozha qiaozha self-assigned this Jan 24, 2024
@qiaozha qiaozha added the HoldOn label Feb 7, 2024
@qiaozha
Copy link
Member

qiaozha commented Mar 6, 2024

pending 1.2.1 release

Comment on lines -26 to +38
const result = await client.string.put(JSON.stringify("test"));
const result = await client.string.put("test", {
requestOptions: {
headers: {
"content-type": "text/plain"
}
}
});
Copy link
Member

Choose a reason for hiding this comment

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

the previous way was working because core client rest will set the requested content type as application/json here but will pass undefined when serialize the request body here, and we will fall into the situation here which will pass the '"test"' to the cadl ranch server end,
but with the core-client-rest 1.3.0,

  1. if we keep passing '"test"' without additional content type information, we will get the into the condition here and get the content type "application/json; charset=UTF-8" and when we serialize the request body with the content type, we will try to JSON.stringify it again. server side will get a """test""".
  2. if we pass the raw string "test" without the content type, as we have decided, we should just leave the content-type as undefined here we will just send out the raw string to cadl ranch, which is wrong too.
    So we have to specify the original string, and the request content type here. and it also works if we set the content type as "application/json".

@joheredi do you think if the core logic is somewhat broken ? or the cureent logic is the right?

@qiaozha qiaozha marked this pull request as ready for review March 14, 2024 11:38
@qiaozha qiaozha merged commit cbe71a7 into Azure:main Mar 18, 2024
28 checks passed
@qiaozha qiaozha deleted the azure-core-basic branch March 18, 2024 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeSpec Azure Core basic scenarios
2 participants