private bool DoWork() { Stream stream = null; string charset = null; bool isgzip = false; SendRequest(TempUrl, out stream, out charset, out isgzip); if (stream == null) { return(false); } string html = null; if (isgzip) { Stream st; EncodeAndCompress.DecompressStream(stream, out st); byte[] buff = new byte[st.Length]; st.Read(buff, 0, buff.Length); html = Encoding.GetEncoding(charset).GetString(buff); st.Close(); } else { var reader = new StreamReader(stream, true); html = reader.ReadToEnd(); reader.Close(); } if (string.IsNullOrEmpty(html)) { return(false); } string tempurl, data; MFunction.Invoke(html, out tempurl, out data); DataStore.SaveFile(data); if (tempurl == null) { return(false); } TempUrl = tempurl; return(true); }
private void ProcessStream(Stream stream, bool isgzip, string charset, out string html) { html = null; if (stream == null) { return; } if (isgzip) { Stream st; EncodeAndCompress.DecompressStream(stream, out st); byte[] buff = new byte[st.Length]; st.Read(buff, 0, buff.Length); html = Encoding.GetEncoding(charset).GetString(buff); st.Close(); } else { var reader = new StreamReader(stream, true); html = reader.ReadToEnd(); reader.Close(); } }
/// <summary> /// 处理接收流 /// </summary> /// <param name="stream"></param> /// <param name="info"></param> /// <param name="html"></param> public void ProcessStream(Stream stream, PageInfo info, out string html) { html = null; if (stream == null) { return; } if (info.IsGzip) { Stream st; EncodeAndCompress.DecompressStream(stream, out st); byte[] buff = new byte[st.Length]; st.Read(buff, 0, buff.Length); html = Encoding.GetEncoding(info.CharSet).GetString(buff); st.Close(); } else { var reader = new StreamReader(stream, true); html = reader.ReadToEnd(); reader.Close(); } }