chiark / gitweb /
server: check part name
[hippotat.git] / src / bin / server.rs
index c3b7b15cd0956e19b07e183ba3b93a502853358a..9446b583825acf79f06d656381aaacf8d52f3822 100644 (file)
@@ -183,6 +183,7 @@ async fn handle(
     // boundary, start, &comp.name, &client.ic);
 
     let (reply_to, reply_recv) = tokio::sync::oneshot::channel();
+    trace!("{} request xxx={}", &client.ic, initial.len());
     let wreq = WebRequest {
       initial,
       initial_remaining,
@@ -192,7 +193,6 @@ async fn handle(
       warnings: mem::take(&mut warnings),
       reply_to
     };
-    trace!("{} request", &client.ic);
 
     client.web.try_send(wreq)
       .map_err(|_| anyhow!("client task shut down!"))?;
@@ -261,7 +261,7 @@ async fn run_client(ic: Arc<InstanceConfig>,
         let WebRequest {
           initial, initial_remaining, length_hint, mut body,
           boundary_finder,
-          reply_to, warnings,
+          reply_to, mut warnings,
         } = req.ok_or_else(|| anyhow!("webservers all shut down!"))?;
 
         match async {
@@ -275,7 +275,7 @@ async fn run_client(ic: Arc<InstanceConfig>,
             &mut body
           ).await.context("read request body")?;
 
-          let (meta, comps) =
+          let (meta, mut comps) =
             multipart::ComponentIterator::resume_mid_component(
               &whole_request[initial_used..],
               boundary_finder
@@ -322,6 +322,13 @@ async fn run_client(ic: Arc<InstanceConfig>,
             let server, client = meta.parse()?.unwrap_or(server);
           }
 
+          while let Some(comp) = comps.next(&mut warnings, PartName::d)? {
+            if comp.name != PartName::d {
+              warnings.add(&format_args!("unexpected part {:?}", comp.name))?;
+            }
+            dbg!(comp.name, DumpHex(comp.payload));
+          }
+
           Ok::<_,AE>(())
         }.await {
           Ok(()) => outstanding.push_back(Outstanding {