@@ -13,7 +13,12 @@ use tokio_util::codec::{Decoder, Encoder};
1313use crate :: client:: log:: { fmt_bin, trace} ;
1414
1515pub const VERSION_FOR_PROTO : & str = env ! ( "DDAPPSEC_VERSION" ) ;
16- const MAX_MESSAGE_SIZE : u32 = 4 * 1024 * 1024 ;
16+ // Incoming messages (PHP extension → helper) can be large when raw response
17+ // body is enabled; both parsed and raw body can each be up to 4 MiB.
18+ const MAX_INCOMING_MSG_SIZE : u32 = 10 * 1024 * 1024 ;
19+ // Outgoing responses (helper → PHP extension) are small by design; keep this
20+ // at 4 MiB to stay within the PHP extension's receive buffer.
21+ const MAX_OUTGOING_MSG_SIZE : u32 = 4 * 1024 * 1024 ;
1722
1823#[ derive( Debug ) ]
1924pub enum Command {
@@ -367,11 +372,11 @@ impl Decoder for CommandCodec {
367372 ) ) ;
368373 }
369374
370- if header. size > MAX_MESSAGE_SIZE {
375+ if header. size > MAX_INCOMING_MSG_SIZE {
371376 return Err ( io:: Error :: new (
372377 io:: ErrorKind :: InvalidData ,
373378 format ! (
374- "Message is too large: {} bytes (supported up to 4 MB )" ,
379+ "Message is too large: {} bytes (supported up to 10 MiB )" ,
375380 header. size
376381 ) ,
377382 ) ) ;
@@ -475,12 +480,12 @@ impl Encoder<CommandResponse<'_>> for CommandCodec {
475480 }
476481
477482 let size = dst. len ( ) - start - header_len;
478- if size > MAX_MESSAGE_SIZE as usize {
483+ if size > MAX_OUTGOING_MSG_SIZE as usize {
479484 dst. truncate ( start) ;
480485 return Err ( io:: Error :: new (
481486 io:: ErrorKind :: InvalidData ,
482487 format ! (
483- "Message is too large: {} bytes (supported up to 4 MB )" ,
488+ "Message is too large: {} bytes (supported up to 4 MiB )" ,
484489 size
485490 ) ,
486491 ) ) ;
0 commit comments