@@ -15,6 +15,11 @@ templates._detail_row = function(wrap)
1515 return [ "tr" , [ "td" , wrap , "colspan" , "2" ] ] ;
1616} ;
1717
18+ templates . wrap_pre = function ( str )
19+ {
20+ return [ "pre" , str , "class" , "mono" ] ;
21+ } ;
22+
1823templates . details = function ( entry , left_val , do_raw )
1924{
2025 return (
@@ -191,11 +196,25 @@ templates._response_headers = function(resp, do_raw)
191196 return [ "tbody" , ret . map ( templates . _detail_row ) ] ;
192197} ;
193198
194- templates . headers_list = function ( headers , firstline )
199+ templates . headers_list = function ( headers , firstline , do_raw )
195200{
196- var lis = headers . map ( function ( header ) {
201+ var map ;
202+ if ( do_raw ) // todo: when raw, this is currently just for headers of parts in mutipart. should be used for others too, to gain the speclinks.
203+ {
204+ map = function ( header )
205+ {
206+ return templates . wrap_pre ( [ [ "span" , header . name + ":" , "data-spec" , "http#" + header . name ] , [ "span" , " " + header . value ] ] ) ;
207+ } ;
208+ }
209+ else
210+ {
211+ map = function ( header )
212+ {
197213 return [ [ "th" , header . name + ":" , "data-spec" , "http#" + header . name ] , [ "td" , header . value ] ] ;
198- } ) ;
214+ } ;
215+ }
216+
217+ var lis = headers . map ( map ) ;
199218
200219 if ( firstline )
201220 {
@@ -204,36 +223,41 @@ templates.headers_list = function(headers, firstline)
204223 return lis ;
205224} ;
206225
207- templates . body_separator = function ( )
208- {
209- return [ "pre" , " " , "class" , "mono" ] ;
210- } ;
211-
212226templates . _request_body = function ( req , do_raw )
213227{
214228 if ( req . requestbody == null )
215229 return [ ] ;
216230
217- var ret = [ templates . body_separator ( ) ] ;
231+ var ret = [ templates . wrap_pre ( "\n" ) ] ;
218232 if ( req . requestbody . partList . length ) // multipart
219233 {
234+ var use_raw_boundary = false ;
235+ if ( do_raw && req . boundary )
236+ use_raw_boundary = true ;
237+
220238 for ( var n = 0 , part ; part = req . requestbody . partList [ n ] ; n ++ )
221239 {
222- ret . concat ( templates . headers_list ( part . headerList ) ) ;
240+ if ( use_raw_boundary && n === 0 )
241+ ret . push ( this . wrap_pre ( req . boundary ) ) ;
242+
243+ ret . extend ( templates . headers_list ( part . headerList , null , do_raw ) ) ;
244+ ret . push ( this . wrap_pre ( "\n" ) ) ;
223245 if ( part . content && part . content . stringData )
224- ret . push ( [ "pre" , part . content . stringData , "class" , "mono" ] ) ;
246+ ret . push ( [ "pre" , part . content . stringData , "class" , "mono network-body " ] ) ;
225247 else
226248 ret . push ( [ "p" , ui_strings . S_NETWORK_N_BYTE_BODY . replace ( "%s" , part . contentLength ) ] ) ;
227249
228250 if ( n < req . requestbody . partList . length - 1 )
229- ret . push ( [ "hr" ] ) ; // todo: when raw, use the boundary here
251+ ret . push ( use_raw_boundary ? this . wrap_pre ( req . boundary ) : [ "hr" ] ) ;
252+ else if ( use_raw_boundary )
253+ ret . push ( this . wrap_pre ( req . boundary + "--\n" ) ) ;
230254 }
231255 }
232256 else if ( req . requestbody . mimeType . startswith ( "application/x-www-form-urlencoded" ) )
233257 {
234258 if ( do_raw )
235259 {
236- ret . push ( [ "pre" , req . requestbody . content . stringData ] ) ;
260+ ret . push ( [ "pre" , req . requestbody . content . stringData , "class" , "mono network-body" ] ) ;
237261 }
238262 else
239263 {
@@ -284,7 +308,7 @@ templates._request_body = function(req, do_raw)
284308
285309templates . _response_body = function ( resp , do_raw , is_last )
286310{
287- var ret = [ templates . body_separator ( ) ] ; // todo: no, then it's (really) empty there shouldn't be a separator either.
311+ var ret = [ templates . wrap_pre ( "\n" ) ] ; // todo: no, then it's (really) empty there shouldn't be a separator either.
288312
289313 var classname = "" ;
290314 if ( resp . body_unavailable ||
0 commit comments