mirror of
https://github.com/danbulant/robotparser-rs
synced 2026-06-13 19:51:55 +00:00
Merge pull request #8 from messense/feature/from-response-mutability
Change from_response method signature
This commit is contained in:
commit
c32933db75
1 changed files with 3 additions and 3 deletions
|
|
@ -248,7 +248,7 @@ impl<'a> RobotFileParser<'a> {
|
|||
let client = Client::new();
|
||||
let request = client.get(self.url.clone())
|
||||
.header(UserAgent(USER_AGENT.to_owned()));
|
||||
let res = match request.send() {
|
||||
let mut res = match request.send() {
|
||||
Ok(res) => res,
|
||||
Err(_) => {
|
||||
return;
|
||||
|
|
@ -261,13 +261,13 @@ impl<'a> RobotFileParser<'a> {
|
|||
status if status >= StatusCode::BadRequest && status < StatusCode::InternalServerError => {
|
||||
self.allow_all.set(true);
|
||||
}
|
||||
StatusCode::Ok => self.from_response(res),
|
||||
StatusCode::Ok => self.from_response(&mut res),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads the HTTP response and feeds it to the parser.
|
||||
pub fn from_response(&self, mut response: Response) {
|
||||
pub fn from_response(&self, response: &mut Response) {
|
||||
let mut buf = String::new();
|
||||
response.read_to_string(&mut buf).unwrap();
|
||||
let lines: Vec<&str> = buf.split('\n').collect();
|
||||
|
|
|
|||
Loading…
Reference in a new issue