|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
CookieContainer containing commas workaroundcookie they are sending down contains some commas in the cookie value part, and this seems to make trouble while coding in dotnet. I'm having difficulties in both directions; when getting the cookie down dotnet splits it to multiple cookies (as if the comma would be the cookie delimiter). and when trying to send back up such a cookie it will throw an exception on the following line: Request.CookieContainer.Add(new Cookie("A","some,commas","/", "www.mysite.com")); Exception="The 'Value'=some,commas' part of the Cookie is invalid." Regardless of what the RFC dictates if this site is using it and it works on all major browsers (tried IE & FireFox) there should be a way to do it in dotnet. so on the way down i overcame it by manually parsing the "Set-Cookie" header. but I'm lost on how to send it back up!! trying to set the Request.Headers["Cookie"] troughs an exception. setting the Request.CookieContainer also throws an exception. so how can i attach this value?? Thus wrote cmk***@gmail.com,
Show quote > I'm working on a spider, which has to crawl a certain site, one of the That's a pretty questionable way to deal with standards. But anyway, Netscape's > cookie they are sending down contains some commas in the cookie value > part, and this seems to make trouble while coding in dotnet. > > I'm having difficulties in both directions; when getting the cookie > down dotnet splits it to multiple cookies (as if the comma would be > the cookie delimiter). > > and when trying to send back up such a cookie it will throw an > exception on the following line: Request.CookieContainer.Add(new > Cookie("A","some,commas","/", "www.mysite.com")); > > Exception="The 'Value'=some,commas' part of the Cookie is invalid." > > Regardless of what the RFC dictates if this site is using it and it > works on all major browsers (tried IE & FireFox) there should be a way > to do it in dotnet. cookie spec also allows to send forbidden characters in URL encoded format, and that works with CookieContainer as well. string val = HttpUtility.UrlEncode("foo,bar"); Cheers, -- Joerg Jooss news-re***@joergjooss.de Thanks, I'll give it a try.
Joerg Jooss wrote: Show quote > Thus wrote cmk***@gmail.com, > > > I'm working on a spider, which has to crawl a certain site, one of the > > cookie they are sending down contains some commas in the cookie value > > part, and this seems to make trouble while coding in dotnet. > > > > I'm having difficulties in both directions; when getting the cookie > > down dotnet splits it to multiple cookies (as if the comma would be > > the cookie delimiter). > > > > and when trying to send back up such a cookie it will throw an > > exception on the following line: Request.CookieContainer.Add(new > > Cookie("A","some,commas","/", "www.mysite.com")); > > > > Exception="The 'Value'=some,commas' part of the Cookie is invalid." > > > > Regardless of what the RFC dictates if this site is using it and it > > works on all major browsers (tried IE & FireFox) there should be a way > > to do it in dotnet. > > That's a pretty questionable way to deal with standards. But anyway, Netscape's > cookie spec also allows to send forbidden characters in URL encoded format, > and that works with CookieContainer as well. > > string val = HttpUtility.UrlEncode("foo,bar"); > request.CookieContainer.Add(new Cookie("foo", val, "/", "www.somewhere.org")); > > Cheers, > -- > Joerg Jooss > news-re***@joergjooss.de |
|||||||||||||||||||||||