mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:52:45 +00:00 
			
		
		
		
	LibWeb/Fetch: Pass recursive=false to manual navigation redirect
Implement ca10f49748
Fixes the issue I found while working on navigation:
https://github.com/whatwg/fetch/issues/1629
			
			
This commit is contained in:
		
							parent
							
								
									7b6cea9ef4
								
							
						
					
					
						commit
						269c25e1d2
					
				
					 2 changed files with 19 additions and 7 deletions
				
			
		|  | @ -923,7 +923,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_fetch(JS::Realm& rea | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         JS::GCPtr<PendingResponse> inner_pending_response; |         Optional<JS::NonnullGCPtr<PendingResponse>> inner_pending_response; | ||||||
| 
 | 
 | ||||||
|         // 7. If actualResponse’s status is a redirect status, then:
 |         // 7. If actualResponse’s status is a redirect status, then:
 | ||||||
|         if (Infrastructure::is_redirect_status(actual_response->status())) { |         if (Infrastructure::is_redirect_status(actual_response->status())) { | ||||||
|  | @ -963,8 +963,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_fetch(JS::Realm& rea | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (inner_pending_response) { |         if (inner_pending_response.has_value()) { | ||||||
|             inner_pending_response->when_loaded([returned_pending_response](JS::NonnullGCPtr<Infrastructure::Response> response) { |             inner_pending_response.value()->when_loaded([returned_pending_response](JS::NonnullGCPtr<Infrastructure::Response> response) { | ||||||
|                 dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'HTTP fetch' inner_pending_response load callback"); |                 dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'HTTP fetch' inner_pending_response load callback"); | ||||||
|                 returned_pending_response->resolve(response); |                 returned_pending_response->resolve(response); | ||||||
|             }); |             }); | ||||||
|  | @ -979,7 +979,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_fetch(JS::Realm& rea | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // https://fetch.spec.whatwg.org/#concept-http-redirect-fetch
 | // https://fetch.spec.whatwg.org/#concept-http-redirect-fetch
 | ||||||
| WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_redirect_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, Infrastructure::Response& response) | WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> http_redirect_fetch(JS::Realm& realm, Infrastructure::FetchParams const& fetch_params, Infrastructure::Response& response) | ||||||
| { | { | ||||||
|     dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'HTTP-redirect fetch' with: fetch_params @ {}, response = {}", &fetch_params, &response); |     dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'HTTP-redirect fetch' with: fetch_params @ {}, response = {}", &fetch_params, &response); | ||||||
| 
 | 
 | ||||||
|  | @ -1108,8 +1108,20 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_redirect_fetch(JS::R | ||||||
| 
 | 
 | ||||||
|     // FIXME: 19. Invoke set request’s referrer policy on redirect on request and actualResponse.
 |     // FIXME: 19. Invoke set request’s referrer policy on redirect on request and actualResponse.
 | ||||||
| 
 | 
 | ||||||
|     // 20. Return the result of running main fetch given fetchParams and true.
 |     // 20. Let recursive be true.
 | ||||||
|     return TRY(main_fetch(realm, fetch_params, Recursive::Yes)).release_value(); |     auto recursive = Recursive::Yes; | ||||||
|  | 
 | ||||||
|  |     // 21. If request’s redirect mode is "manual", then:
 | ||||||
|  |     if (request->redirect_mode() == Infrastructure::Request::RedirectMode::Manual) { | ||||||
|  |         // 1. Assert: request’s mode is "navigate".
 | ||||||
|  |         VERIFY(request->mode() == Infrastructure::Request::Mode::Navigate); | ||||||
|  | 
 | ||||||
|  |         // 2. Set recursive to false.
 | ||||||
|  |         recursive = Recursive::No; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // 22. Return the result of running main fetch given fetchParams and recursive.
 | ||||||
|  |     return main_fetch(realm, fetch_params, recursive); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // https://fetch.spec.whatwg.org/#concept-http-network-or-cache-fetch
 | // https://fetch.spec.whatwg.org/#concept-http-network-or-cache-fetch
 | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS:: | ||||||
| WebIDL::ExceptionOr<void> fetch_response_handover(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response&); | WebIDL::ExceptionOr<void> fetch_response_handover(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response&); | ||||||
| WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> scheme_fetch(JS::Realm&, Infrastructure::FetchParams const&); | WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> scheme_fetch(JS::Realm&, Infrastructure::FetchParams const&); | ||||||
| WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_fetch(JS::Realm&, Infrastructure::FetchParams const&, MakeCORSPreflight make_cors_preflight = MakeCORSPreflight::No); | WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_fetch(JS::Realm&, Infrastructure::FetchParams const&, MakeCORSPreflight make_cors_preflight = MakeCORSPreflight::No); | ||||||
| WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_redirect_fetch(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response&); | WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> http_redirect_fetch(JS::Realm&, Infrastructure::FetchParams const&, Infrastructure::Response&); | ||||||
| WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fetch(JS::Realm&, Infrastructure::FetchParams const&, IsAuthenticationFetch is_authentication_fetch = IsAuthenticationFetch::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No); | WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fetch(JS::Realm&, Infrastructure::FetchParams const&, IsAuthenticationFetch is_authentication_fetch = IsAuthenticationFetch::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No); | ||||||
| WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> nonstandard_resource_loader_file_or_http_network_fetch(JS::Realm&, Infrastructure::FetchParams const&, IncludeCredentials include_credentials = IncludeCredentials::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No); | WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> nonstandard_resource_loader_file_or_http_network_fetch(JS::Realm&, Infrastructure::FetchParams const&, IncludeCredentials include_credentials = IncludeCredentials::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No); | ||||||
| WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> cors_preflight_fetch(JS::Realm&, Infrastructure::Request&); | WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> cors_preflight_fetch(JS::Realm&, Infrastructure::Request&); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Aliaksandr Kalenik
						Aliaksandr Kalenik