File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -347,6 +347,24 @@ pub fn handle_publisher_request(
347347
348348 log:: info!( "Request host: {}, scheme: {}" , request_host, request_scheme) ;
349349
350+ // Generate synthetic identifiers before the request body is consumed.
351+ let synthetic_id = get_or_generate_synthetic_id ( settings, & req) ?;
352+ let has_synthetic_cookie = req
353+ . get_header ( header:: COOKIE )
354+ . and_then ( |h| h. to_str ( ) . ok ( ) )
355+ . map ( |cookies| {
356+ cookies
357+ . split ( ';' )
358+ . any ( |cookie| cookie. trim_start ( ) . starts_with ( "synthetic_id=" ) )
359+ } )
360+ . unwrap_or ( false ) ;
361+
362+ log:: info!(
363+ "Proxy synthetic IDs - trusted: {}, has_cookie: {}" ,
364+ synthetic_id,
365+ has_synthetic_cookie
366+ ) ;
367+
350368 // Extract host from the origin_url using the Publisher's origin_host method
351369 let origin_host = settings. publisher . origin_host ( ) ;
352370
@@ -434,6 +452,14 @@ pub fn handle_publisher_request(
434452 ) ;
435453 }
436454
455+ response. set_header ( HEADER_SYNTHETIC_TRUSTED_SERVER , synthetic_id. as_str ( ) ) ;
456+ if !has_synthetic_cookie {
457+ response. set_header (
458+ header:: SET_COOKIE ,
459+ create_synthetic_cookie ( settings, synthetic_id. as_str ( ) ) ,
460+ ) ;
461+ }
462+
437463 Ok ( response)
438464}
439465
You can’t perform that action at this time.
0 commit comments