HttpWebResponse httpresp = response as HttpWebResponse;
if (httpresp != null) {
string contentDisposition = httpresp.Headers["Content-Disposition"];
-
if (! string.IsNullOrEmpty(contentDisposition)) {
// おかしな Content-Disposition ヘッダ向け
- //(Content-Disposition: filename=\"...\" に attachment; を補って RFC1806 に準拠させる)
- if (System.Text.RegularExpressions.Regex.IsMatch(contentDisposition, @" *filename=", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) {
+ // attachment と書いていないでいきなりfilenameからはじまるとき、attachment; を補って RFC1806 に準拠させる
+ if (System.Text.RegularExpressions.Regex.IsMatch(contentDisposition, @"^ *filename=", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) {
contentDisposition = "attachment; " + contentDisposition;
}
// "atachment;filename=\""のようにセミコロンの後ろにスペースがない場合、それを補充する