@@ -1881,7 +1881,8 @@ fn generate_local_message_handler(
18811881 Source: {:?}\n \
18821882 Body: {}\n \
18831883 \n \
1884- 💡 This usually means the message format doesn't match any of your #[local] or #[remote] handlers.",
1884+ 💡 This usually means the message format doesn't match any of your #[local] or #[remote] handlers.\n \
1885+ 💡 If you are sending an HTTP message, if it is malformed, it might have ended up in the local message handler.",
18851886 e, message. source( ) , raw_body
18861887 ) ;
18871888 }
@@ -1955,35 +1956,21 @@ fn generate_message_handlers(
19551956 #websocket_client_handler
19561957 }
19571958 /// Handle messages from the HTTP server
1958- fn handle_http_server_message( state: * mut #self_ty, message: hyperware_process_lib:: Message ) {
1959- let blob_opt = message. blob( ) ;
1960-
1961- match serde_json:: from_slice:: <hyperware_process_lib:: http:: server:: HttpServerRequest >( message. body( ) ) {
1962- Ok ( http_server_request) => {
1963- match http_server_request {
1964- hyperware_process_lib:: http:: server:: HttpServerRequest :: Http ( http_request) => {
1965- hyperware_process_lib:: logging:: debug!( "Processing HTTP request, message has blob: {}" , blob_opt. is_some( ) ) ;
1966- if let Some ( ref blob) = blob_opt {
1967- hyperware_process_lib:: logging:: debug!( "Blob size: {} bytes, content: {}" , blob. bytes. len( ) , String :: from_utf8_lossy( & blob. bytes[ ..std:: cmp:: min( 200 , blob. bytes. len( ) ) ] ) ) ;
1968- }
1969-
1970- #http_context_setup
1971- #http_request_parsing
1972- #http_dispatcher
1973- } ,
1974- #websocket_handlers
1959+ fn handle_http_server_message( state: * mut #self_ty, http_server_request: hyperware_process_lib:: http:: server:: HttpServerRequest , blob_opt: Option <hyperware_process_lib:: LazyLoadBlob >) {
1960+ match http_server_request {
1961+ hyperware_process_lib:: http:: server:: HttpServerRequest :: Http ( http_request) => {
1962+ hyperware_process_lib:: logging:: debug!( "Processing HTTP request, message has blob: {}" , blob_opt. is_some( ) ) ;
1963+ if let Some ( ref blob) = blob_opt {
1964+ hyperware_process_lib:: logging:: debug!( "Blob size: {} bytes, content: {}" , blob. bytes. len( ) , String :: from_utf8_lossy( & blob. bytes[ ..std:: cmp:: min( 200 , blob. bytes. len( ) ) ] ) ) ;
19751965 }
1966+ #http_context_setup
1967+ #http_request_parsing
1968+ #http_dispatcher
19761969 } ,
1977- Err ( e) => {
1978- hyperware_process_lib:: logging:: error!(
1979- "Failed to parse HTTP server request: {}\n \
1980- This usually indicates a malformed message to the HTTP server.",
1981- e
1982- ) ;
1983- }
1970+ #websocket_handlers
19841971 }
19851972 }
1986-
1973+
19871974 #local_message_handler
19881975 #remote_message_handler
19891976 #eth_message_handler
@@ -2197,7 +2184,11 @@ fn generate_component_impl(
21972184 }
21982185 hyperware_process_lib:: Message :: Request { .. } => {
21992186 if message. is_local( ) && message. source( ) . process == "http-server:distro:sys" {
2200- handle_http_server_message( & mut state, message) ;
2187+ if let Ok ( http_server_request) = serde_json:: from_slice:: <hyperware_process_lib:: http:: server:: HttpServerRequest >( message. body( ) ) {
2188+ handle_http_server_message( & mut state, http_server_request, message. blob( ) ) ;
2189+ } else {
2190+ handle_local_message( & mut state, message) ;
2191+ }
22012192 } else if message. is_local( ) && message. source( ) . process == "http-client:distro:sys" {
22022193 handle_websocket_client_message( & mut state, message) ;
22032194 } else if message. is_local( ) && message. source( ) . process == "eth:distro:sys" {
0 commit comments