@@ -176,9 +176,19 @@ def __init__(self, crawler):
176176 def _get_header_set (request ):
177177 return {header .strip ().lower () for header in request .headers }
178178
179- def process_start_requests (self , start_requests , spider ):
179+ async def process_start (self , start ):
180180 # Mark start requests and reports to the downloader middleware the
181181 # number of them once all have been processed.
182+ count = 0
183+ async for item_or_request in start :
184+ if isinstance (item_or_request , Request ):
185+ count += 1
186+ item_or_request .meta ["is_start_request" ] = True
187+ self ._process_output_request (item_or_request , None )
188+ yield item_or_request
189+ self ._send_signal (_start_requests_processed , count = count )
190+
191+ def process_start_requests (self , start_requests , spider ):
182192 count = 0
183193 for item_or_request in start_requests :
184194 if isinstance (item_or_request , Request ):
@@ -189,7 +199,8 @@ def process_start_requests(self, start_requests, spider):
189199 self ._send_signal (_start_requests_processed , count = count )
190200
191201 def _process_output_request (self , request , spider ):
192- request .meta ["_pre_mw_headers" ] = self ._get_header_set (request )
202+ if "_pre_mw_headers" not in request .meta :
203+ request .meta ["_pre_mw_headers" ] = self ._get_header_set (request )
193204 self .slot_request (request , spider )
194205
195206 def _process_output_item_or_request (self , item_or_request , spider ):
0 commit comments