-
Notifications
You must be signed in to change notification settings - Fork 1k
Expose response headers in DocsService
#6191
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
Changes from 3 commits
d2e617a
ed925b2
0c5f150
d788723
23fac82
9b9921c
718f68e
9705ab2
296645f
08f344b
56e3d2c
46af150
8306d0c
62839b8
add4c40
5e1fa52
690f573
61f864c
abdad9b
a9b8f6e
5836119
a9bab84
e0cef46
aa14f38
a7dbee2
8f2f600
5260cee
295debf
b4309dc
67bf1fd
7f8a887
d1ac966
52f2271
355f172
d0d668e
0f1501c
25614a5
8763d92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -31,7 +31,7 @@ export default abstract class Transport { | |||||
| bodyJson?: string, | ||||||
| endpointPath?: string, | ||||||
| queries?: string, | ||||||
| ): Promise<string> { | ||||||
| ): Promise<{ body: string; headers: Record<string, string> }> { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should return
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your review ! Belows are the changes :
RFC9110 specifies: "A sender MUST NOT generate multiple header fields with the same field name unless the entire field value is comma-separated or the field explicitly allows multiple field lines." Thus, I defined Replaced Response with Adjusted DebugPage header display: When server set headers like this : Now, multi-value headers appear correctly as below:
If you have any feedback or suggestions, I’d really appreciate your comments!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! It looks much better. However, I'd like you to consider the following:
Therefore, what do you think about using plaintext rather than JSON to render the response headers?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also note that the following are considered different, although they are semantically same: vs. .. which means we need to preserve the ordering, which cannot be achieved by using a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initially, I didn’t consider the preservation of header order or merging rules. For example, the Date header value like "Sat, 19 Apr 2025 09:00:00 GMT" includes a comma as part of the value. Initially, I implemented naive comma-splitting across all headers. The updated logic iterates through the response Headers object:
|
||||||
| const providedHeaders = await Promise.all( | ||||||
| providers.map((provider) => provider()), | ||||||
| ); | ||||||
|
|
@@ -59,25 +59,45 @@ export default abstract class Transport { | |||||
| endpointPath, | ||||||
| queries, | ||||||
| ); | ||||||
| const responseHeaders = this.extractHeaders(httpResponse.headers); | ||||||
| const responseText = await httpResponse.text(); | ||||||
| const applicationType = httpResponse.headers.get('content-type') || ''; | ||||||
| if (applicationType.indexOf('json') >= 0) { | ||||||
| try { | ||||||
| const json = JSONbig.parse(responseText); | ||||||
| const prettified = jsonPrettify(JSONbig.stringify(json)); | ||||||
| if (prettified.length > 0) { | ||||||
| return prettified; | ||||||
| return { | ||||||
| body: prettified, | ||||||
| headers: responseHeaders, | ||||||
| }; | ||||||
| } | ||||||
| } catch (e) { | ||||||
| return responseText; | ||||||
| return { | ||||||
| body: responseText, | ||||||
| headers: responseHeaders, | ||||||
| }; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (responseText.length > 0) { | ||||||
| return responseText; | ||||||
| return { | ||||||
| body: responseText, | ||||||
| headers: responseHeaders, | ||||||
| }; | ||||||
| } | ||||||
| return { | ||||||
| body: '<zero-length response>', | ||||||
| headers: responseHeaders, | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
| return '<zero-length response>'; | ||||||
| protected extractHeaders(headers: Headers): Record<string, string> { | ||||||
| const result: Record<string, string> = {}; | ||||||
| headers.forEach((value, key) => { | ||||||
| result[key] = value; | ||||||
| }); | ||||||
| return result; | ||||||
| } | ||||||
|
|
||||||
| public findDebugMimeTypeEndpoint( | ||||||
|
|
||||||


Uh oh!
There was an error while loading. Please reload this page.