Confusing problem while using Mechanize to submit a form wit

i have met a very confusing problem while using Mechanize to submit a
form with a file return. how should i save the file? thanks a lot for
any response :slight_smile:

code here:

url =
"http://xxxx.com/abc.aspx?CurDate=2008-12-08&PingID=93761&IPAddress=172.28.33.179

agent = WWW::Mechanize.new {|a| a.log = Logger.new(β€œmechanize.log”) }
p = agent.get(url)
form = p.form(β€œForm1”)
agent.submit(form, form.buttons[0])

log here:

D, [2008-12-08T12:05:09.049021 #3242] DEBUG – : response-header:
cache-control => private
D, [2008-12-08T12:05:09.049063 #3242] DEBUG – : response-header:
x-aspnet-version => 1.1.4322
D, [2008-12-08T12:05:09.049103 #3242] DEBUG – : response-header:
content-type => text/html; charset=gb2312
D, [2008-12-08T12:05:09.049143 #3242] DEBUG – : response-header:
x-powered-by => ASP.NET
D, [2008-12-08T12:05:09.049182 #3242] DEBUG – : response-header: date
=> Mon, 08 Dec 2008 03:58:11 GMT
D, [2008-12-08T12:05:09.049222 #3242] DEBUG – : response-header: server
=> Microsoft-IIS/5.0
D, [2008-12-08T12:05:09.049261 #3242] DEBUG – : response-header:
content-length => 8383
D, [2008-12-08T12:05:09.049300 #3242] DEBUG – : response-header:
set-cookie => ASP.NET_SessionId=3soop5yp5kyjscefjsqo0h45; path=/
D, [2008-12-08T12:05:09.049516 #3242] DEBUG – : saved cookie:
ASP.NET_SessionId=3soop5yp5kyjscefjsqo0h45
I, [2008-12-08T12:05:09.049587 #3242] INFO – : status: 200
D, [2008-12-08T12:05:59.419232 #3242] DEBUG – : query:
β€œ__VIEWSTATE=dDwtMTU0MDc0MzM4MDt0PHA8bDxQaW5nSUQ7SVBBZGRyZXNzO1dBTklQO0N1ckRhdGU7PjtsPDkzNzYxOzE3Mi4yOC4zMy4xNzk7MTE4LjEyMy4yMzQuMjAyOzIwMDgtMTItMDg7Pj47bDxpPDE%2BOz47bDx0PDtsPGk8MT47PjtsPHQ8cDw7cDxsPHRpdGxlOz47bDzlj6%2Flr7zlh7rlpJbnvZHjgIHlhoXnvZHjgIFDUFXkvb%2FnlKjnjofjgIFDUFXotJ%2Fovb3jgIHno4Hnm5hJT%2BOAgeWGheWtmOS9v%2BeUqOetieaVsOaNrjs%2BPj47Oz47Pj47Pj47PjPEuhpeDjb5ZcAUlT%2F0eZdcs0%2FW&btnExportSingle=%B5%BC%B3%F6%B5%A5%BB%FA%CA%FD%BE%DD”
I, [2008-12-08T12:05:59.420382 #3242] INFO – : Net::HTTP::Post: ===
thisisurl ===
D, [2008-12-08T12:05:59.420436 #3242] DEBUG – : request-header:
accept-language => en-us,en;q=0.5
D, [2008-12-08T12:05:59.420478 #3242] DEBUG – : request-header:
connection => keep-alive
D, [2008-12-08T12:05:59.420518 #3242] DEBUG – : request-header: accept
=> /
D, [2008-12-08T12:05:59.420558 #3242] DEBUG – : request-header:
accept-encoding => gzip,identity
D, [2008-12-08T12:05:59.420598 #3242] DEBUG – : request-header:
content-type => application/x-www-form-urlencoded
D, [2008-12-08T12:05:59.420638 #3242] DEBUG – : request-header:
user-agent => WWW-Mechanize/0.8.5
(http://rubyforge.org/projects/mechanize/)
D, [2008-12-08T12:05:59.420679 #3242] DEBUG – : request-header: cookie
=> ASP.NET_SessionId=3soop5yp5kyjscefjsqo0h45
D, [2008-12-08T12:05:59.420719 #3242] DEBUG – : request-header: referer
=>
http://ied-monitor.itil.com/TNM/Details/BasicView.aspx?CurDate=2008-12-08&PingID=93761&IPAddress=172.28.33.179&WANIP=118.123.234.202
D, [2008-12-08T12:05:59.420785 #3242] DEBUG – : request-header:
accept-charset => ISO-8859-1,utf-8;q=0.7,*;q=0.7
D, [2008-12-08T12:05:59.420826 #3242] DEBUG – : request-header:
content-length => 443
D, [2008-12-08T12:05:59.420866 #3242] DEBUG – : request-header: host =>
ied-monitor.itil.com
D, [2008-12-08T12:05:59.420905 #3242] DEBUG – : request-header:
keep-alive => 300
D, [2008-12-08T12:05:59.667624 #3242] DEBUG – : Read 0 bytes
D, [2008-12-08T12:05:59.708634 #3242] DEBUG – : Read 1024 bytes
D, [2008-12-08T12:05:59.708802 #3242] DEBUG – : Read 2048 bytes
D, [2008-12-08T12:05:59.708941 #3242] DEBUG – : Read 3072 bytes
D, [2008-12-08T12:05:59.709082 #3242] DEBUG – : Read 4096 bytes
D, [2008-12-08T12:05:59.709221 #3242] DEBUG – : Read 5120 bytes
D, [2008-12-08T12:05:59.709358 #3242] DEBUG – : Read 6144 bytes
D, [2008-12-08T12:05:59.709496 #3242] DEBUG – : Read 7168 bytes
D, [2008-12-08T12:05:59.709637 #3242] DEBUG – : Read 8192 bytes
D, [2008-12-08T12:05:59.709775 #3242] DEBUG – : Read 9216 bytes
D, [2008-12-08T12:05:59.709912 #3242] DEBUG – : Read 10240 bytes
D, [2008-12-08T12:05:59.710049 #3242] DEBUG – : Read 11264 bytes
D, [2008-12-08T12:05:59.710188 #3242] DEBUG – : Read 12288 bytes
D, [2008-12-08T12:05:59.710325 #3242] DEBUG – : Read 13312 bytes
D, [2008-12-08T12:05:59.710462 #3242] DEBUG – : Read 14336 bytes
D, [2008-12-08T12:05:59.710611 #3242] DEBUG – : Read 15360 bytes
D, [2008-12-08T12:05:59.710753 #3242] DEBUG – : Read 16384 bytes
D, [2008-12-08T12:05:59.710891 #3242] DEBUG – : Read 17408 bytes
D, [2008-12-08T12:05:59.711028 #3242] DEBUG – : Read 18432 bytes
D, [2008-12-08T12:05:59.711166 #3242] DEBUG – : Read 19456 bytes
D, [2008-12-08T12:05:59.711303 #3242] DEBUG – : Read 20480 bytes
D, [2008-12-08T12:05:59.711439 #3242] DEBUG – : Read 21504 bytes
D, [2008-12-08T12:05:59.711574 #3242] DEBUG – : Read 22528 bytes
D, [2008-12-08T12:05:59.711703 #3242] DEBUG – : Read 23552 bytes
D, [2008-12-08T12:05:59.711832 #3242] DEBUG – : Read 24576 bytes
D, [2008-12-08T12:05:59.711962 #3242] DEBUG – : Read 25600 bytes
D, [2008-12-08T12:05:59.712091 #3242] DEBUG – : Read 26624 bytes
D, [2008-12-08T12:05:59.712221 #3242] DEBUG – : Read 27648 bytes
D, [2008-12-08T12:05:59.712349 #3242] DEBUG – : Read 28672 bytes
D, [2008-12-08T12:05:59.712479 #3242] DEBUG – : Read 29696 bytes
D, [2008-12-08T12:05:59.712608 #3242] DEBUG – : Read 30720 bytes
D, [2008-12-08T12:05:59.712740 #3242] DEBUG – : Read 31744 bytes
D, [2008-12-08T12:05:59.714021 #3242] DEBUG – : Read 32768 bytes
D, [2008-12-08T12:05:59.714185 #3242] DEBUG – : Read 33792 bytes
D, [2008-12-08T12:05:59.714322 #3242] DEBUG – : Read 34816 bytes
D, [2008-12-08T12:05:59.714456 #3242] DEBUG – : Read 35840 bytes
D, [2008-12-08T12:05:59.714603 #3242] DEBUG – : Read 36864 bytes
D, [2008-12-08T12:05:59.714738 #3242] DEBUG – : Read 37888 bytes
D, [2008-12-08T12:05:59.714873 #3242] DEBUG – : Read 38912 bytes
D, [2008-12-08T12:05:59.715007 #3242] DEBUG – : Read 39936 bytes
D, [2008-12-08T12:05:59.715142 #3242] DEBUG – : Read 40960 bytes
D, [2008-12-08T12:05:59.715276 #3242] DEBUG – : Read 41984 bytes
D, [2008-12-08T12:05:59.715421 #3242] DEBUG – : Read 43008 bytes
D, [2008-12-08T12:05:59.715555 #3242] DEBUG – : Read 44032 bytes
D, [2008-12-08T12:05:59.715690 #3242] DEBUG – : Read 45056 bytes
D, [2008-12-08T12:05:59.715824 #3242] DEBUG – : Read 46080 bytes
D, [2008-12-08T12:05:59.715960 #3242] DEBUG – : Read 47104 bytes
D, [2008-12-08T12:05:59.716096 #3242] DEBUG – : Read 48128 bytes
D, [2008-12-08T12:05:59.716232 #3242] DEBUG – : Read 49152 bytes
D, [2008-12-08T12:05:59.716366 #3242] DEBUG – : Read 50176 bytes
D, [2008-12-08T12:05:59.716499 #3242] DEBUG – : Read 51200 bytes
D, [2008-12-08T12:05:59.716634 #3242] DEBUG – : Read 52224 bytes
D, [2008-12-08T12:05:59.716767 #3242] DEBUG – : Read 53248 bytes
D, [2008-12-08T12:05:59.716903 #3242] DEBUG – : Read 54272 bytes
D, [2008-12-08T12:05:59.717035 #3242] DEBUG – : Read 55296 bytes
D, [2008-12-08T12:05:59.717163 #3242] DEBUG – : Read 56320 bytes
D, [2008-12-08T12:05:59.717305 #3242] DEBUG – : Read 57344 bytes
D, [2008-12-08T12:05:59.717435 #3242] DEBUG – : Read 58368 bytes
D, [2008-12-08T12:05:59.717564 #3242] DEBUG – : Read 59392 bytes
D, [2008-12-08T12:05:59.717693 #3242] DEBUG – : Read 60416 bytes
D, [2008-12-08T12:05:59.717822 #3242] DEBUG – : Read 61440 bytes
D, [2008-12-08T12:05:59.717952 #3242] DEBUG – : Read 62464 bytes
D, [2008-12-08T12:05:59.718081 #3242] DEBUG – : Read 63488 bytes
D, [2008-12-08T12:05:59.718220 #3242] DEBUG – : Read 64512 bytes
D, [2008-12-08T12:05:59.718371 #3242] DEBUG – : Read 65536 bytes
D, [2008-12-08T12:05:59.718522 #3242] DEBUG – : Read 66560 bytes
D, [2008-12-08T12:05:59.718651 #3242] DEBUG – : Read 67584 bytes
D, [2008-12-08T12:05:59.718789 #3242] DEBUG – : Read 68608 bytes
D, [2008-12-08T12:05:59.718920 #3242] DEBUG – : Read 69632 bytes
D, [2008-12-08T12:05:59.719049 #3242] DEBUG – : Read 70656 bytes
D, [2008-12-08T12:05:59.719177 #3242] DEBUG – : Read 70972 bytes
E, [2008-12-08T12:05:59.719860 #3242] ERROR – : Rescuing EOF error


request header:

POST /abc.aspx?CurDate=2008-12-08&PingID=93761&IPAddress=172.28.33.179
HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/x-silverlight, /
Referer:
http://xxxxx.com/abc.aspx?CurDate=2008-12-08&PingID=93761&IPAddress=172.28.33.179
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
QQDownload 1.7; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
; .NET CLR 1.1.4322; CIBA; .NET CLR 2.0.50727)
Host: xxxxx.com
Content-Length: 443
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: TCOA=tO6OcyMRDT;
TCOA_TICKET=D42F3A45624719B040CB3D2D0A6F964987C6CBEADC4A474385C9E102A63832F330364FD6C40DB79EE7F58D4D8215309B45770FAE2F7E86C314C07A5C773129315138DAA9F6A8364B598CC8C6AB09D05A470825150C5E54BA329DEE7D35861FD231B03800ED5F4E04ED04CF05F99BD6B25EE0A3601E645DBAABD3FFED3BEB3B786F09B7B137BB7F981A87F1C89427EA9B155ACCF596BC5D52ED89E639B75E6D9FBEDBF4A8BD2F4E1D;
ASP.NET_SessionId=gcefx3v0jacvxg45uthmha2i;
ITILUserInfo=LoginName=angusguan&ChineseName=%b9%d8%d2%e5%b4%ba&DepName=%bb%a5%b6%af%d3%e9%c0%d6%ca%c2%d2%b5%b2%bf

__VIEWSTATE=dDwtMTU0MDc0MzM4MDt0PHA8bDxQaW5nSUQ7S


response header:

HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.0
Date: Mon, 08 Dec 2008 02:23:04 GMT
X-Powered-By: ASP.NET

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Mon, 08 Dec 2008 02:23:04 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
content-disposition: attachment; filename=172.28.33.179Traffic.xls
Transfer-Encoding: chunked
Cache-Control: private
Content-Type: application/vnd.ms-excel