mirror of
https://github.com/lxsang/luafcgi.git
synced 2024-12-26 05:08:23 +01:00
fix: improve protocol implementations to comply with the FastCGI specification
All checks were successful
gitea-sync/luafcgi/pipeline/head This commit looks good
All checks were successful
gitea-sync/luafcgi/pipeline/head This commit looks good
This commit is contained in:
parent
3153cc48af
commit
77cfca2fac
16
src/lib.rs
16
src/lib.rs
@ -728,7 +728,9 @@ impl FCGIOStream {
|
||||
loop {
|
||||
let length = {
|
||||
let buffer = buf_reader.fill_buf()?;
|
||||
if buffer.len() > 0 {
|
||||
fcgi_send_stdout(self, self.id, Some(buffer.to_vec()))?;
|
||||
}
|
||||
buffer.len()
|
||||
};
|
||||
if length == 0 {
|
||||
@ -1532,7 +1534,10 @@ fn fcgi_decode_strlen(data: &[u8]) -> usize {
|
||||
}
|
||||
}
|
||||
|
||||
fn fcgi_decode_params(rq: &mut FGCIRequest, data: &Vec<u8>) -> Result<(), std::io::Error> {
|
||||
fn fcgi_decode_params(rq: &mut FGCIRequest, vec: &Vec<u8>) -> Result<(), std::io::Error> {
|
||||
let mut pos = 0;
|
||||
while pos < vec.len() {
|
||||
let data = &vec[pos..];
|
||||
let mut index: usize = 1;
|
||||
let key_len = fcgi_decode_strlen(data);
|
||||
if key_len > 127 {
|
||||
@ -1545,16 +1550,19 @@ fn fcgi_decode_params(rq: &mut FGCIRequest, data: &Vec<u8>) -> Result<(), std::i
|
||||
} else {
|
||||
index += 1;
|
||||
}
|
||||
//INFO!("data: {:?}", data);
|
||||
//INFO!("key: {:?}", data[index..index + key_len].to_vec());
|
||||
//INFO!("Value: {:?}", data[index+key_len..index+key_len+value_len].to_vec());
|
||||
//DEBUG!("data: {:?}", data);
|
||||
//DEBUG!("key: {:?}", data[index..index + key_len].to_vec());
|
||||
//DEBUG!("Value: {:?}", data[index+key_len..index+key_len+value_len].to_vec());
|
||||
let key = String::from_utf8(data[index..index + key_len].to_vec())
|
||||
.map_err(|e| ERR!(e.to_string()))?;
|
||||
let value: String =
|
||||
String::from_utf8(data[index + key_len..index + key_len + value_len].to_vec())
|
||||
.map_err(|e| ERR!(e.to_string()))?;
|
||||
DEBUG!("PARAM: [{}] -> [{}]", key, value);
|
||||
pos = pos + index + key_len + value_len;
|
||||
|
||||
let _ = rq.params.insert(key, value);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user