send_str to send_string
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
//! These top level http method functions create a [Request](struct.Request.html) instance
|
//! These top level http method functions create a [Request](struct.Request.html) instance
|
||||||
//! which follows a build pattern. The builders are finished using
|
//! which follows a build pattern. The builders are finished using
|
||||||
//! [`.call()`](struct.Request.html#method.call),
|
//! [`.call()`](struct.Request.html#method.call),
|
||||||
//! [`.send_str()`](struct.Request.html#method.send_str) or
|
//! [`.send_string()`](struct.Request.html#method.send_string) or
|
||||||
//! [`.send_json()`](struct.Request.html#method.send_json).
|
//! [`.send_json()`](struct.Request.html#method.send_json).
|
||||||
//!
|
//!
|
||||||
//! # Agents
|
//! # Agents
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
//! # Content-Length
|
//! # Content-Length
|
||||||
//!
|
//!
|
||||||
//! The library will set the content length on the request when using
|
//! The library will set the content length on the request when using
|
||||||
//! [`.send_str()`](struct.Request.html#method.send_str) or
|
//! [`.send_string()`](struct.Request.html#method.send_string) or
|
||||||
//! [`.send_json()`](struct.Request.html#method.send_json). In other cases the user
|
//! [`.send_json()`](struct.Request.html#method.send_json). In other cases the user
|
||||||
//! can optionally `request.set("Content-Length", 1234)`.
|
//! can optionally `request.set("Content-Length", 1234)`.
|
||||||
//!
|
//!
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//! let resp = ureq::post("http://my-server.com/ingest")
|
//! let resp = ureq::post("http://my-server.com/ingest")
|
||||||
//! .set("Transfer-Encoding", "chunked")
|
//! .set("Transfer-Encoding", "chunked")
|
||||||
//! .send_str("Hello world");
|
//! .send_string("Hello world");
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
extern crate ascii;
|
extern crate ascii;
|
||||||
|
|||||||
@@ -186,10 +186,10 @@ impl Request {
|
|||||||
/// ```
|
/// ```
|
||||||
/// let r = ureq::post("/my_page")
|
/// let r = ureq::post("/my_page")
|
||||||
/// .content_type("text/plain")
|
/// .content_type("text/plain")
|
||||||
/// .send_str("Hello World!");
|
/// .send_string("Hello World!");
|
||||||
/// println!("{:?}", r);
|
/// println!("{:?}", r);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn send_str<S>(&mut self, data: S) -> Response
|
pub fn send_string<S>(&mut self, data: S) -> Response
|
||||||
where
|
where
|
||||||
S: Into<String>,
|
S: Into<String>,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ impl Response {
|
|||||||
/// Tells if this response is "synthetic".
|
/// Tells if this response is "synthetic".
|
||||||
///
|
///
|
||||||
/// The [methods](struct.Request.html#method.call) [firing](struct.Request.html#method.send)
|
/// The [methods](struct.Request.html#method.call) [firing](struct.Request.html#method.send)
|
||||||
/// [off](struct.Request.html#method.send_str) [requests](struct.Request.html#method.send_json)
|
/// [off](struct.Request.html#method.send_string) [requests](struct.Request.html#method.send_json)
|
||||||
/// all return a `Response`; there is no rust style `Result`.
|
/// all return a `Response`; there is no rust style `Result`.
|
||||||
///
|
///
|
||||||
/// Rather than exposing a custom error type through results, this library has opted
|
/// Rather than exposing a custom error type through results, this library has opted
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fn content_length_on_str() {
|
|||||||
test::make_response(200, "OK", vec![], vec![])
|
test::make_response(200, "OK", vec![], vec![])
|
||||||
});
|
});
|
||||||
let resp = get("test://host/content_length_on_str")
|
let resp = get("test://host/content_length_on_str")
|
||||||
.send_str("Hello World!!!");
|
.send_string("Hello World!!!");
|
||||||
let vec = resp.to_write_vec();
|
let vec = resp.to_write_vec();
|
||||||
let s = String::from_utf8_lossy(&vec);
|
let s = String::from_utf8_lossy(&vec);
|
||||||
assert!(s.contains("\r\nContent-Length: 14\r\n"));
|
assert!(s.contains("\r\nContent-Length: 14\r\n"));
|
||||||
@@ -21,7 +21,7 @@ fn user_set_content_length_on_str() {
|
|||||||
});
|
});
|
||||||
let resp = get("test://host/user_set_content_length_on_str")
|
let resp = get("test://host/user_set_content_length_on_str")
|
||||||
.set("Content-Length", "12345")
|
.set("Content-Length", "12345")
|
||||||
.send_str("Hello World!!!");
|
.send_string("Hello World!!!");
|
||||||
let vec = resp.to_write_vec();
|
let vec = resp.to_write_vec();
|
||||||
let s = String::from_utf8_lossy(&vec);
|
let s = String::from_utf8_lossy(&vec);
|
||||||
assert!(s.contains("\r\nContent-Length: 12345\r\n"));
|
assert!(s.contains("\r\nContent-Length: 12345\r\n"));
|
||||||
@@ -48,7 +48,7 @@ fn content_length_and_chunked() {
|
|||||||
});
|
});
|
||||||
let resp = post("test://host/content_length_and_chunked")
|
let resp = post("test://host/content_length_and_chunked")
|
||||||
.set("Transfer-Encoding", "chunked")
|
.set("Transfer-Encoding", "chunked")
|
||||||
.send_str("Hello World!!!");
|
.send_string("Hello World!!!");
|
||||||
let vec = resp.to_write_vec();
|
let vec = resp.to_write_vec();
|
||||||
let s = String::from_utf8_lossy(&vec);
|
let s = String::from_utf8_lossy(&vec);
|
||||||
assert!(s.contains("Transfer-Encoding: chunked\r\n"));
|
assert!(s.contains("Transfer-Encoding: chunked\r\n"));
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use test;
|
|
||||||
|
|
||||||
use super::super::*;
|
use super::super::*;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user