@@ -225,7 +225,16 @@ impl<L: QuoteGenerator, R: QuoteVerifier> ProxyServer<L, R> {
225225 if let Some ( measurements) = measurements {
226226 let headers = req. headers_mut ( ) ;
227227
228- headers. insert ( MEASUREMENT_HEADER , measurements. to_header_format ( ) . unwrap ( ) ) ;
228+ match measurements. to_header_format ( ) {
229+ Ok ( header_value) => {
230+ headers. insert ( MEASUREMENT_HEADER , header_value) ;
231+ }
232+ Err ( e) => {
233+ // This error is highly unlikely - that the measurement values fail to
234+ // encode to JSON or fit in an HTTP header
235+ eprintln ! ( "Failed to encode measurement values: {e}" ) ;
236+ }
237+ }
229238 }
230239
231240 async move {
@@ -262,7 +271,7 @@ impl<L: QuoteGenerator, R: QuoteVerifier> ProxyServer<L, R> {
262271 // Drive the connection
263272 tokio:: spawn ( async move {
264273 if let Err ( e) = conn. await {
265- eprintln ! ( "client conn error: {e}" ) ;
274+ eprintln ! ( "Client connection error: {e}" ) ;
266275 }
267276 } ) ;
268277
@@ -532,15 +541,24 @@ impl<L: QuoteGenerator, R: QuoteVerifier> ProxyClient<L, R> {
532541 // Drive the connection
533542 tokio:: spawn ( async move {
534543 if let Err ( e) = conn. await {
535- eprintln ! ( "client conn error: {e}" ) ;
544+ eprintln ! ( "Client connection error: {e}" ) ;
536545 }
537546 } ) ;
538547
539548 match sender. send_request ( req) . await {
540549 Ok ( mut resp) => {
541550 if let Some ( measurements) = measurements {
542551 let headers = resp. headers_mut ( ) ;
543- headers. insert ( MEASUREMENT_HEADER , measurements. to_header_format ( ) . unwrap ( ) ) ;
552+ match measurements. to_header_format ( ) {
553+ Ok ( header_value) => {
554+ headers. insert ( MEASUREMENT_HEADER , header_value) ;
555+ }
556+ Err ( e) => {
557+ // This error is highly unlikely - that the measurement values fail to
558+ // encode to JSON or fit in an HTTP header
559+ eprintln ! ( "Failed to encode measurement values: {e}" ) ;
560+ }
561+ }
544562 }
545563 Ok ( resp. map ( |b| b. boxed ( ) ) )
546564 }
0 commit comments