src/client/http_client.rs: implement h2 upload
without flow control so far ...
This commit is contained in:
parent
dafc27aeff
commit
97f22ce57d
|
@ -407,6 +407,22 @@ impl H2Client {
|
||||||
self.request(req)
|
self.request(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn upload(&self, path: &str, param: Option<Value>, data: Vec<u8>) -> impl Future<Item=Value, Error=Error> {
|
||||||
|
let request = Self::request_builder("localhost", "POST", path, param).unwrap();
|
||||||
|
|
||||||
|
self.h2.clone()
|
||||||
|
.ready()
|
||||||
|
.map_err(Error::from)
|
||||||
|
.and_then(move |mut send_request| {
|
||||||
|
let (response, mut stream) = send_request.send_request(request, false).unwrap();
|
||||||
|
// fixme: implement flow control
|
||||||
|
stream.send_data(bytes::Bytes::from(data), true);
|
||||||
|
response
|
||||||
|
.map_err(Error::from)
|
||||||
|
.and_then(Self::h2api_response)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn request(
|
fn request(
|
||||||
&self,
|
&self,
|
||||||
request: Request<()>,
|
request: Request<()>,
|
||||||
|
@ -416,7 +432,6 @@ impl H2Client {
|
||||||
.ready()
|
.ready()
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.and_then(move |mut send_request| {
|
.and_then(move |mut send_request| {
|
||||||
// fixme: what about stream/upload?
|
|
||||||
let (response, _stream) = send_request.send_request(request, true).unwrap();
|
let (response, _stream) = send_request.send_request(request, true).unwrap();
|
||||||
response
|
response
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
|
|
Loading…
Reference in New Issue