def build_output_stream(args, env, request, response, output_options):
 req_h = (OUT_REQ_HEAD in output_options)
 req_b = (OUT_REQ_BODY in output_options)
 resp_h = (OUT_RESP_HEAD in output_options)
 resp_b = (OUT_RESP_BODY in output_options)
 req = (req_h or req_b)
 resp = (resp_h or resp_b)
 output = []
 Stream = get_stream_type(env, args)
 if req:
  output.append(Stream(msg=HTTPRequest(request), with_headers=req_h, with_body=req_b))
 if (req_b and resp):
  output.append(['\n\n'])
 if resp:
  output.append(Stream(msg=HTTPResponse(response), with_headers=resp_h, with_body=resp_b))
 if (env.stdout_isatty and resp_b):
  output.append(['\n\n'])
 return chain(*output)

def build_output_stream ( args , env , request , response , output_options ) : req_h = ( OUT_REQ_HEAD in output_options ) req_b = ( OUT_REQ_BODY in output_options ) resp_h = ( OUT_RESP_HEAD in output_options ) resp_b = ( OUT_RESP_BODY in output_options ) req = ( req_h or req_b ) resp = ( resp_h or resp_b ) output = [ ] Stream = get_stream_type ( env , args ) if req : output . append ( Stream ( msg = HTTPRequest ( request ) , with_headers = req_h , with_body = req_b ) ) if ( req_b and resp ) : output . append ( [ '\n\n' ] ) if resp : output . append ( Stream ( msg = HTTPResponse ( response ) , with_headers = resp_h , with_body = resp_b ) ) if ( env . stdout_isatty and resp_b ) : output . append ( [ '\n\n' ] ) return chain ( * output )
build and return a chain of iterators over the request-response exchange each of which yields bytes chunks .