@@ -14,7 +14,7 @@ import { reportError } from '../../../errors';
14
14
15
15
import { AccountStore } from '../../../model/account/account-store' ;
16
16
import { UiStore } from '../../../model/ui-store' ;
17
- import { generateHarRequest , generateHar } from '../../../model/http/har' ;
17
+ import { generateHarRequest , generateHar , ExtendedHarRequest } from '../../../model/http/har' ;
18
18
19
19
import { ProHeaderPill , CardSalesPitch } from '../../account/pro-placeholders' ;
20
20
import {
@@ -84,13 +84,33 @@ const snippetEditorOptions = {
84
84
hover : { enabled : false }
85
85
} ;
86
86
87
- const simplifyHarForSnippetExport = ( harRequest : HarFormat . Request ) => {
87
+ const simplifyHarForSnippetExport = ( harRequest : ExtendedHarRequest ) => {
88
+ const postData = ! ! harRequest . postData
89
+ ? harRequest . postData
90
+ : harRequest . _requestBodyStatus === 'discarded:not-representable'
91
+ ? {
92
+ mimeType : 'text/plain' ,
93
+ text : "!!! UNREPRESENTABLE BINARY REQUEST BODY - BODY MUST BE EXPORTED SEPARATELY !!!"
94
+ }
95
+ : harRequest . _requestBodyStatus === 'discarded:too-large'
96
+ ? {
97
+ mimeType : 'text/plain' ,
98
+ text : "!!! VERY LARGE REQUEST BODY - BODY MUST BE EXPORTED & INCLUDED SEPARATELY !!!"
99
+ }
100
+ : harRequest . _requestBodyStatus === 'discarded:not-decodable'
101
+ ? {
102
+ mimeType : 'text/plain' ,
103
+ text : "!!! REQUEST BODY COULD NOT BE DECODED !!!"
104
+ }
105
+ : undefined ;
106
+
88
107
// When exporting code snippets the primary goal is to generate convenient code to send the
89
108
// request that's *sematantically* equivalent to the original request, not to force every
90
109
// tool to produce byte-for-byte identical requests (that's effectively impossible). To do
91
110
// this, we drop headers that tools can produce automatically for themselves:
92
111
return {
93
112
...harRequest ,
113
+ postData,
94
114
headers : _ . filter ( harRequest . headers , ( header ) => {
95
115
// All clients should be able to automatically generate the correct content-length
96
116
// headers as required for a request where it's unspecified. If we override this,
0 commit comments