@@ -41,6 +41,8 @@ def read_password_from_config
4141BASE_URL = env_or_default ( "BASE_URL" , "localhost:3800" )
4242PROTOCOL_VERSION = read_protocol_version
4343LOAD_GENERATOR_SHARDS = env_or_default ( "LOAD_GENERATOR_SHARDS" , 1 ) . to_i
44+ RAW_RENDER_CONTENT_TYPE = "application/vnd.react-on-rails.render-request+javascript"
45+ RAW_RENDER_PROTOCOL_HEADER = "X-React-On-Rails-Pro-Protocol-Version"
4446
4547# Test cases: JavaScript expressions to evaluate
4648# Format: { name: "test_name", request: "javascript_code", rsc: true/false }
@@ -105,8 +107,10 @@ def rsc_bundle?(bundle_timestamp)
105107 # Use curl with h2c since Net::HTTP doesn't support HTTP/2
106108 result , status = Open3 . capture2 (
107109 "curl" , "-s" , "--http2-prior-knowledge" , "-X" , "POST" ,
108- "-H" , "Content-Type: application/x-www-form-urlencoded" ,
109- "-d" , body ,
110+ "-H" , "Content-Type: #{ RAW_RENDER_CONTENT_TYPE } " ,
111+ "-H" , "#{ RAW_RENDER_PROTOCOL_HEADER } : #{ PROTOCOL_VERSION } " ,
112+ "-H" , "Authorization: Bearer #{ PASSWORD } " ,
113+ "--data-binary" , body ,
110114 url
111115 )
112116 return nil unless status . success?
@@ -145,23 +149,14 @@ def categorize_bundles(bundles)
145149 [ rsc_bundle , non_rsc_bundle ]
146150end
147151
148- # URL-encode special characters for form body
149- def url_encode ( str )
150- URI . encode_www_form_component ( str )
151- end
152-
153152# Build render URL for a bundle and render name
154153def render_url ( bundle_timestamp , render_name )
155154 "http://#{ BASE_URL } /bundles/#{ bundle_timestamp } /render/#{ render_name } "
156155end
157156
158157# Build request body for a rendering request
159158def render_body ( rendering_request )
160- [
161- "protocolVersion=#{ url_encode ( PROTOCOL_VERSION ) } " ,
162- "password=#{ url_encode ( PASSWORD ) } " ,
163- "renderingRequest=#{ url_encode ( rendering_request ) } "
164- ] . join ( "&" )
159+ rendering_request
165160end
166161
167162def validate_node_renderer_benchmark_config!
@@ -380,7 +375,9 @@ def run_vegeta_benchmark(test_case, bundle_timestamp, shard_count: LOAD_GENERATO
380375 # Write targets file (Vegeta format with @body reference)
381376 File . write ( targets_file , <<~TARGETS )
382377 POST #{ target_url }
383- Content-Type: application/x-www-form-urlencoded
378+ Content-Type: #{ RAW_RENDER_CONTENT_TYPE }
379+ #{ RAW_RENDER_PROTOCOL_HEADER } : #{ PROTOCOL_VERSION }
380+ Authorization: Bearer #{ PASSWORD }
384381 @#{ body_file }
385382 TARGETS
386383
0 commit comments