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

fix: populate content-type header for all event messages #3760

Merged
merged 1 commit into from
Jun 29, 2022

Conversation

AllanZhengYP
Copy link
Contributor

@AllanZhengYP AllanZhengYP commented Jun 29, 2022

Issue

Associated with: smithy-lang/smithy-typescript#567
Ref: P66766800

Description

Populate the :content-type header for all the event messages. It was missed previously. When the payload shape is blob, the value is application/octet-stream; When the payload shape is string, the value is text/plain, When the payload shape is Union or Structure, the value is the protocol's content type.

Testing

  • Transcribe-streaming
    automated integration test
  • Lex-runtime-v2
    Manual test, automated integration test not added because it relies on other client to spin up resources. Will create follow-up item.
import { LexRuntimeV2Client, StartConversationCommand } from "@aws-sdk/client-lex-runtime-v2";

const client = new LexRuntimeV2Client({});
const stream = async function* () {
 yield {
   ConfigurationEvent: {
     responseContentType: "text/plain; charset=utf-8",
   },
 };
 yield {
   TextInputEvent: {
     text: "Order flowers",
   },
 };
};

const command = new StartConversationCommand({
 botId,
 botAliasId,
 localeId: "en_US",
 sessionId: Date.now() + "",
 conversationMode: "TEXT",
 // @ts-ignore
 requestEventStream: stream(),
});

const response = client.send(command);
response
 .then(async (resp) => {
   try {
     for await (const event of resp.responseEventStream) {
       if (event.TranscriptEvent) {
         console.log(event.TranscriptEvent.transcript);
       }
     }
   } catch (e) {
     console.error(e);
   }
 })
 .catch((e) => console.error(e));
// Output: Order flowers

Additional context

Add any other context about the PR here.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@AllanZhengYP AllanZhengYP requested a review from a team as a code owner June 29, 2022 00:18
@AllanZhengYP AllanZhengYP requested a review from kuhe June 29, 2022 00:21
@AllanZhengYP AllanZhengYP merged commit 4f3d41e into aws:main Jun 29, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants