public void GetHeaders(HeaderCb cb) { String name = ""; String value = ""; bool done = false; using (StringReader reader = new StringReader(GetString())) { String line = ""; while (done == false && (line = reader.ReadLine()) != null) { Match m = Regex.Match(line, "^([^\t :]+):(.*)$"); // matched header: field if (m.Success) { // call with last consumed header/value. new header means all (if any) values with FWS are consumed if (name != "") { done = cb(name, value); } name = m.Groups[1].Value.ToLower(); value = m.Groups[2].Value.TrimStart(' '); } // must be FWS else if (name != "") { value += " " + line.TrimStart(' '); } } } if (name != "" && done == false) { cb(name, value); } }
public void GetHeaders(HeaderCb cb) { String name = ""; String value = ""; bool done = false; using (StringReader reader = new StringReader(GetString())) { String line = ""; while (done == false && (line = reader.ReadLine()) != null) { Match m = Regex.Match(line, "^([^\t :]+):(.*)$"); // matched header: field if (m.Success) { // call with last consumed header/value. new header means all (if any) values with FWS are consumed if (name != "") done = cb(name, value); name = m.Groups[1].Value.ToLower(); value = m.Groups[2].Value.TrimStart(' '); } // must be FWS else if (name != "") { value += " " + line.TrimStart(' '); } } } if (name != "" && done == false) cb(name, value); }