Merge pull request #125 from chills42/no-more-rustc-serialize
refactor(transport-smtp): migrate away from rustc-serialize
This commit is contained in:
@@ -16,7 +16,8 @@ email = "^0.0"
|
||||
log = "^0.3"
|
||||
mime = "^0.2"
|
||||
openssl = "^0.9"
|
||||
rustc-serialize = "^0.3"
|
||||
base64 = "~0.5.0"
|
||||
hex = "^0.2.0"
|
||||
rust-crypto = "^0.2"
|
||||
time = "^0.1"
|
||||
uuid = { version = "^0.5", features = ["v4"] }
|
||||
|
||||
@@ -277,7 +277,8 @@
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
extern crate mime;
|
||||
extern crate rustc_serialize;
|
||||
extern crate base64;
|
||||
extern crate hex;
|
||||
extern crate crypto;
|
||||
extern crate time;
|
||||
extern crate uuid;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use crypto::hmac::Hmac;
|
||||
use crypto::mac::Mac;
|
||||
use crypto::md5::Md5;
|
||||
use rustc_serialize::hex::ToHex;
|
||||
use hex::ToHex;
|
||||
use std::fmt;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use transport::smtp::NUL;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use bufstream::BufStream;
|
||||
use openssl::ssl::SslContext;
|
||||
|
||||
use rustc_serialize::base64::{self, FromBase64, ToBase64};
|
||||
use base64;
|
||||
use std::fmt::Debug;
|
||||
use std::io;
|
||||
use std::io::{BufRead, Read, Write};
|
||||
@@ -204,9 +204,7 @@ impl<S: Connector + Timeout + Write + Read + Debug> Client<S> {
|
||||
if mechanism.supports_initial_response() {
|
||||
self.command(&format!("AUTH {} {}",
|
||||
mechanism,
|
||||
try!(mechanism.response(username, password, None))
|
||||
.as_bytes()
|
||||
.to_base64(base64::STANDARD)))
|
||||
base64::encode_config(try!(mechanism.response(username, password, None)).as_bytes(), base64::STANDARD)))
|
||||
} else {
|
||||
let encoded_challenge = match try!(self.command(&format!("AUTH {}", mechanism)))
|
||||
.first_word() {
|
||||
@@ -216,7 +214,7 @@ impl<S: Connector + Timeout + Write + Read + Debug> Client<S> {
|
||||
|
||||
debug!("auth encoded challenge: {}", encoded_challenge);
|
||||
|
||||
let decoded_challenge = match encoded_challenge.from_base64() {
|
||||
let decoded_challenge = match base64::decode(&encoded_challenge) {
|
||||
Ok(challenge) => {
|
||||
match String::from_utf8(challenge) {
|
||||
Ok(value) => value,
|
||||
@@ -231,11 +229,10 @@ impl<S: Connector + Timeout + Write + Read + Debug> Client<S> {
|
||||
let mut challenge_expected = 3;
|
||||
|
||||
while challenge_expected > 0 {
|
||||
let response = try!(self.command(&try!(mechanism.response(username,
|
||||
let response = try!(self.command(&base64::encode_config(&try!(mechanism.response(username,
|
||||
password,
|
||||
Some(&decoded_challenge)))
|
||||
.as_bytes()
|
||||
.to_base64(base64::STANDARD)));
|
||||
.as_bytes(), base64::STANDARD)));
|
||||
|
||||
if !response.has_code(334) {
|
||||
return Ok(response);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Error and result type for SMTP clients
|
||||
|
||||
use self::Error::*;
|
||||
use rustc_serialize::base64::FromBase64Error;
|
||||
use base64::DecodeError;
|
||||
use std::error::Error as StdError;
|
||||
use std::fmt;
|
||||
use std::fmt::{Display, Formatter};
|
||||
@@ -23,7 +23,7 @@ pub enum Error {
|
||||
/// Error parsing a response
|
||||
ResponseParsing(&'static str),
|
||||
/// Error parsing a base64 string in response
|
||||
ChallengeParsing(FromBase64Error),
|
||||
ChallengeParsing(DecodeError),
|
||||
/// Error parsing UTF8in response
|
||||
Utf8Parsing(FromUtf8Error),
|
||||
/// Internal client error
|
||||
|
||||
Reference in New Issue
Block a user