@@ -109,9 +109,16 @@ def from_args(
109109 processor_func , target_dict = rules [arg .sep ]
110110 value = processor_func (arg )
111111
112+ # NEW: handle multi-header files
113+ if isinstance (value , list ):
114+ # value is a list of (key, value) pairs
115+ for k , v in value :
116+ target_dict .add (k , v )
117+ continue # Skip normal handling
118+
119+ # Normal case
112120 if arg .sep in SEPARATORS_GROUP_MULTIPART :
113121 instance .multipart_data [arg .key ] = value
114-
115122 if isinstance (target_dict , BaseMultiDict ):
116123 target_dict .add (arg .key , value )
117124 else :
@@ -127,8 +134,21 @@ def process_header_arg(arg: KeyValueArg) -> Optional[str]:
127134 return arg .value or None
128135
129136
130- def process_embed_header_arg (arg : KeyValueArg ) -> str :
131- return load_text_file (arg ).rstrip ('\n ' )
137+ def process_embed_header_arg (arg : KeyValueArg ):
138+ text = load_text_file (arg ).rstrip ('\n ' )
139+ lines = [line .strip () for line in text .splitlines () if line .strip ()]
140+
141+ header_pairs = []
142+
143+ for i , line in enumerate (lines , start = 1 ):
144+ if ':' not in line :
145+ raise ParseError (f"{ arg .orig !r} : Malformed header on line { i } : { line !r} " )
146+
147+ key , value = line .split (':' , 1 )
148+ header_pairs .append ((key .strip (), value .strip ()))
149+
150+ return header_pairs
151+
132152
133153
134154def process_empty_header_arg (arg : KeyValueArg ) -> str :
0 commit comments