mirror of
https://github.com/helix-editor/helix.git
synced 2025-01-19 13:37:06 +04:00
lsp: slightly refactor header parsing, add more logging
This commit is contained in:
parent
d6a9c2c0f6
commit
7eff905680
@ -1,7 +1,7 @@
|
|||||||
use crate::Result;
|
use crate::Result;
|
||||||
use anyhow::Context;
|
use anyhow::{anyhow, Context};
|
||||||
use jsonrpc_core as jsonrpc;
|
use jsonrpc_core as jsonrpc;
|
||||||
use log::{error, info};
|
use log::{debug, error, info};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -83,20 +83,16 @@ async fn recv_server_message(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut parts = header.split(": ");
|
debug!("<- header {}", header);
|
||||||
|
|
||||||
match (parts.next(), parts.next(), parts.next()) {
|
let parts = header.split_once(": ");
|
||||||
(Some("Content-Length"), Some(value), None) => {
|
|
||||||
|
match parts {
|
||||||
|
Some(("Content-Length", value)) => {
|
||||||
content_length = Some(value.parse().context("invalid content length")?);
|
content_length = Some(value.parse().context("invalid content length")?);
|
||||||
}
|
}
|
||||||
(Some(_), Some(_), None) => {}
|
Some((_, _)) => {}
|
||||||
_ => {
|
None => return Err(anyhow!("Failed to parse header: {:?}", header).into()),
|
||||||
return Err(std::io::Error::new(
|
|
||||||
std::io::ErrorKind::Other,
|
|
||||||
"Failed to parse header",
|
|
||||||
)
|
|
||||||
.into());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user