Browse Source
This commit fixes writes to stdout/stderr which don't end in a newline to not get split across lines with a prefix on each line. Instead internally a flag is used to track whether a prefix is required at the beginning of each chunk.pull/8887/head
Alex Crichton
4 months ago
committed by
GitHub
3 changed files with 125 additions and 21 deletions
@ -0,0 +1,30 @@ |
|||
use std::io::Write; |
|||
use test_programs::proxy; |
|||
use test_programs::wasi::http::types::{ |
|||
Fields, IncomingRequest, OutgoingResponse, ResponseOutparam, |
|||
}; |
|||
|
|||
struct T; |
|||
|
|||
proxy::export!(T); |
|||
|
|||
impl proxy::exports::wasi::http::incoming_handler::Guest for T { |
|||
fn handle(_request: IncomingRequest, outparam: ResponseOutparam) { |
|||
print!("this is half a print "); |
|||
std::io::stdout().flush().unwrap(); |
|||
println!("to stdout"); |
|||
println!(); // empty line
|
|||
println!("after empty"); |
|||
|
|||
eprint!("this is half a print "); |
|||
std::io::stderr().flush().unwrap(); |
|||
eprintln!("to stderr"); |
|||
eprintln!(); // empty line
|
|||
eprintln!("after empty"); |
|||
|
|||
let resp = OutgoingResponse::new(Fields::new()); |
|||
ResponseOutparam::set(outparam, Ok(resp)); |
|||
} |
|||
} |
|||
|
|||
fn main() {} |
Loading…
Reference in new issue