.net - VB.NET - [HTTP POST] Response.Cookies is only returning first cookie value -
i'm using following code loop throught response cookies , save them in cookiejar.
each tempcookie cookie in response.cookies cookiejar.add(tempcookie) msgbox(tempcookie.tostring) next
it happens it's returning 1 cookie, first 1 (only runs once in for):
page_vis=a|186.213.98.144|1381089446.485193|
response.cookies has 1 cookie on it, response.headers has of them.
how parse them response.headers , add on cookiecontainer use them later? cookies in response.headers here:
set-cookie: page_vis=a|186.213.98.144|1381089446.485193|; domain=page; path=/; expires=mon, 07-oct-2013 06:00:00 gmt,csasf=;version=1;domain=page;path=/;max-age=7776000,csapages=ekpeowluwtzsmxpdswrmmm8wwwz3ut09|5749|knm6h4hlob4swlfg2goimxxpmtxdd5tnvb/dj7as3muquiltphlxzswjfksi1rcq6fp/dkre3qhazhpqi968iw==;version=1;domain=page;path=/;max-age=7776000;httponly,nam_login_default=user;version=1;domain=page;path=/;max-age=129600,upl09=2-25|39|54|56|58|90|91|105|106|156|182|212|218|219|242|245|248|284|285|480|1222;version=1;domain=page;path=/;max-age=2592000,page_otr=;version=1;domain=page;path=/;max-age=2592000,caubr01=5eeouuddqyj+ilcq7oog71yxegigi2kj7bjditt27ttxgjt7jqc49egprgjz+8rq7o7mqg/qeq28u4exaiebfe0qqi9qqurj27lreai4kszacsstao5yy+yqzyfr4qggcp18ods/y92mketqeucoxug+qsk5fhojmkqqqpxqe07orqen2jgehohvmoqqqkcqeq78+2emqtkzlrvmqv2qmkmqeqqoiqz72nkgrxo2mkeskkwkzq2ch7grc+ggokocqovmqeoqekbr82ejqcgkvhoqqn2qkemqkk2xlqek20eetsr2qo2kqerqeqqodqzh7ykgtxk2mcesmemsgqvstmzb24ekumrtqw2qqeoqeqqk92zumnkzsokqmo2kqeokeq2kzqkpvvkzlocmqo7qqgmmkq2omeeimxgzbkmqqoqqqkxqzsqv2vk32teg+cr7kh2qqekqemqct7g726zggk9qsxvmqkoqgkqmkrkvq1zenooeskmqmzkqkq7x82g1ehgkwxkvmoqqqzcseqvoqqe/2jkzjokmqk2sqzmkkqjocmzb7yekkmktqcqqmgosgqvxq2ehqgke0rkqqkqqqkckeq7xjqgiedgkukkvmoqqqzcskq7kcqz/vdkzzkcmqw7kqgmmkqqoqek+msgzpkmqqkuqqkxqzsqkb2exc8gzkko2ko9sqkoqekqxmqgteqkkihk/qoqqqzxskq9odqgz2skzokkmqk2mszmkeqqkbmzi7pkk3mkvqcqqmeosgqvkhqzbc9kgoxoqqmesqktqkqmk/2zfqtzzeokqqo2kqgosgq2kfckxqhekq9xqqk7qsgoqzqeoqmzn7ngk2mk7qcqqmzokgqvksqzjulkgjxo7qmesqgwqkqmcj7g07azgwk9qqxvmqkoqgkqmorkwqszg4ooesomqmzkqkq2xa2kh2aeetmw2ko7qqeoqeq7mlvkiqfegroo/qkmqszkqeq7xr7gxemgkutkvmoqqqzcsgqck9qzgvhkzcrcmqo7qqgmmkqqo3ezemogz8kmqqrqkqkxqzsqrtvkrqhggucx7qkqqsgkqzmerqmzf79zkrmkbkcqqmkokgqvkzqzgczkgtxoqqmesqz8kkqmcg7ghqfzecknqqxvmqkrqgmqmkmkuqjzzxoreskmqszkqzk7xcqgzehgkb4kvmoqqkzcszqtrf2z07gegstkbqcqqmgosgqvkeqz52dkghxobqmesqeckkqmcd7glb8zkxkoqqxvmqkwqgqqm/qkqq9zeqoweskmqkzkqek7x0bgrejgklvkvmoqqkzcseqjkbqzuvikzdwcmqh7mqgmmkqboqeetm0gzhkmqqw9kqkxqzsqm7vksq9ggocx7mkbqsgkqzmewdmzv7vekemk/kcqqmkosgqvk0qzseqkgqxobqmesqkskkqmc97goubzekkkqqxvmqkvqgqqme7keqdzkdoveskmqkzkqzk7x6ugeedgktwkvmoqqkzcskqukjqghvtkztvcmq97kqgmmkquonekjmrgzxkmqqvrkqkxqzsqxevkqqfkgqcx7mkuqsgkqzmevrmzm7wkkdmkvkcqqmeosgqvklqzecvkgnxouqmesqktkkqmcv7gbjjzz1koqqxvmqk8qgqqmlqkyqlzgio8eskmqqzkqgk7xfjguetgk/rkvmoqqkzcsgqbksqkkvskzr8cmq87kqgmmkqjotegymqgzgkmqq8ckqkxqzsqnzvkdq3egzcx7mkjqsgkqzme8xmzq7tgksmkmkcqqmzosgqvkdqzfthkgxxojqmesqg4kkqmco7g7c0zgfkcqqxvmqk8qgsqm72ksqizzwo9eskmqqzkqkm7mgvc;version=1;domain=page;path=/
why isn't getting rest of cookies, first one?
how solve that?
the entire function in here:
private function logonpage(byval url string, byref cookiejar cookiecontainer, byval postdata string) dim reader streamreader dim request httpwebrequest = httpwebrequest.create(url) request.method = "post" request.useragent = "mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.8.1.14) gecko/20080404 firefox/2.0.0.14" request.cookiecontainer = cookiejar request.allowautoredirect = false request.contenttype = "application/x-www-form-urlencoded" request.contentlength = postdata.length dim requeststream stream = request.getrequeststream() dim postbytes byte() = encoding.ascii.getbytes(postdata) requeststream.write(postbytes, 0, postbytes.length) requeststream.close() dim response httpwebresponse = request.getresponse() each tempcookie cookie in response.cookies cookiejar.add(tempcookie) next reader = new streamreader(response.getresponsestream()) return reader.readtoend() response.close() end function
tell me i'm doing wrong, , if it's possible, point me solution? thank much.
in case of multiple cookies, set-cookie
header might contain cookies separated comma ,
while cookie properties separated semicolon ;
, response.headers("set-cookie")
returns cookies in string
.
- apply cookie separation technique on
response.headers("set-cookie")
- extract each cookie's name, value, path, domain etc.
- create
cookie
objects information - add cookies
cookiecontainer
.
note splitting cookies on comma ,
not useful because cookie property expires might contain comma in expires=mon, 07-oct-2013 06:00:00 gmt:
dim strcookies string = response.headers("set-cookie") ' splitting on comma example dim cookies() string = strcookies.split(commadelimeter, stringsplitoptions.removeemptyentries) each ck string in cookies dim ckprop() string = ck.split(semicolondelimeter, stringsplitoptions.removeemptyentries) dim cookie new cookie(ckprop(0), ckprop(1)) cookiejar.add(cookie) next ck
Comments
Post a Comment