473,811 Members | 3,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET Cookie Parsing

Is there a decent cookie parser out there somewhere? I keep running into
cookies that .NET can't handle. I've also found a couple of other parsers
but they're choking as well.
Jun 27 '08 #1
5 8874
As I dig a little deeper into it, it appears that .NET is parsing the
Set-Cookie header properly. The cookies are even split up properly in the
private members deep down. But somehow they're getting *mangled* on their
way back up when you try to actually access them. This doesn't make a lot
of sense to me. Anyone had any experience with this? Hints, tips? Thanks.

"Mike C#" <xy*@xyz.comwro te in message
news:uG******** ******@TK2MSFTN GP04.phx.gbl...
Is there a decent cookie parser out there somewhere? I keep running into
cookies that .NET can't handle. I've also found a couple of other parsers
but they're choking as well.

Jun 27 '08 #2
Do you have a bare bone repro for this ?

I had this once in classic ASP if you put characters that are themselves
used to separate cookies one from the other or to separate the cookie name
and value. Encoding those values should fix the problem.

--
Patrice
"Mike C#" <xy*@xyz.coma écrit dans le message de news:
OJ************* *@TK2MSFTNGP05. phx.gbl...
As I dig a little deeper into it, it appears that .NET is parsing the
Set-Cookie header properly. The cookies are even split up properly in the
private members deep down. But somehow they're getting *mangled* on their
way back up when you try to actually access them. This doesn't make a lot
of sense to me. Anyone had any experience with this? Hints, tips?
Thanks.

"Mike C#" <xy*@xyz.comwro te in message
news:uG******** ******@TK2MSFTN GP04.phx.gbl...
>Is there a decent cookie parser out there somewhere? I keep running into
cookies that .NET can't handle. I've also found a couple of other
parsers but they're choking as well.


Jun 27 '08 #3
I did some investigation, it turns out that the CookieCollectio n uses a
too-simple string split function instead of actually attempting to "parse"
the cookie. So any cookies that contain commas get mangled. I then tried
to grab the data from the Set-Cookie header, but those values get mangled in
a similar fashion. What's really annoying is that I can see the properly
parsed values in Visual Studio, way down in the private members of the
headers collection, but they're not exposed anywhere except in the Visual
Studio watch window. I ended up creating my own better parser to handle it.
The website I was playing around with was Expedia.com, BTW. I imagine there
are probably a lot of other websites that use commas in cookies - they
should fix the handling behaviour in .NET.

"Patrice" <http://www..chez.com/scribe/wrote in message
news:48******** *************@n ews.orange.fr.. .
Do you have a bare bone repro for this ?

I had this once in classic ASP if you put characters that are themselves
used to separate cookies one from the other or to separate the cookie name
and value. Encoding those values should fix the problem.

--
Patrice
"Mike C#" <xy*@xyz.coma écrit dans le message de news:
OJ************* *@TK2MSFTNGP05. phx.gbl...
>As I dig a little deeper into it, it appears that .NET is parsing the
Set-Cookie header properly. The cookies are even split up properly in the
private members deep down. But somehow they're getting *mangled* on
their way back up when you try to actually access them. This doesn't
make a lot of sense to me. Anyone had any experience with this? Hints,
tips? Thanks.

"Mike C#" <xy*@xyz.comwro te in message
news:uG******* *******@TK2MSFT NGP04.phx.gbl.. .
>>Is there a decent cookie parser out there somewhere? I keep running
into cookies that .NET can't handle. I've also found a couple of other
parsers but they're choking as well.



Jun 27 '08 #4
Mike C# wrote :

"I ended up creating my own better parser to handle it."

Hi Mike,

I imagine there are many people, besides myself, who would really appreciate
a brief tutorial and your solution if you have the time, inclination, and
freedom from contractual constraint, that would allow you to post an article
on CodeProject or a similar venue, or share code.

thanks, Bill
Jun 27 '08 #5
"Bill Woodruff" <bi***@dotscien ce.comwrote in message
news:u5******** ******@TK2MSFTN GP02.phx.gbl...
Mike C# wrote :

"I ended up creating my own better parser to handle it."

Hi Mike,

I imagine there are many people, besides myself, who would really
appreciate
a brief tutorial and your solution if you have the time, inclination, and
freedom from contractual constraint, that would allow you to post an
article
on CodeProject or a similar venue, or share code.
This particular piece of code was part of a work for hire, so I can't post
it without permission. I'll discuss with the person I'm writing it for and
see if they're willing to allow it. If not, I may write another version of
the solution (time permitting) and post that. I really believe the absolute
best solution would be for the .NET team to fix the problem in the
Framework, but until then I guess we just have to make do with custom
parsing solutions :(
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3584
by: Ben Hearsum | last post by:
I'm confused about the way Cookie.load outputs cookies. Is there a way I can tell it to give me the value of a key? I set my cookie like this: mycookie = Cookie.SimpleCookie() mycookie = "foobar" print mycookie print("Content-Type: text/html\n\n")
13
2125
by: Manlio Perillo | last post by:
Hi. I'm using the Cookie module (on the client side). I have found a problem trying to parse the cookie: "Set-Cookie: value=thevalue; path=/; expires=Fri, 21-May-2004 10:40:51 GMT" The date is not parsed correctly, only "Fri," is matched.
5
5186
by: Alex Hunsley | last post by:
I'm using urllib to post data to a web form by issuing a command similar to this: filename, headers = urllib.urlretrieve("http://www.thewebsitenamehere.com/servlet/com.blah.bloo.XmlFeed", "content.txt", None, urllib.urlencode({"aParameter": "theValue"})) Now, the problem is that the above fails, since I am not sending a session cookie. Visitors to the web sites' html submission form are sent a session cookie which is given back to...
5
3317
by: brettr | last post by:
When I reference document.cookie, there is a long string of key=value; pairs listed. I may have 100 hundred cookies on my hard drive. However, most only have one key=value pair. Does the document.cookie variable combine all cookie key=value pairs? All of the examples I've seen discuss referencing a specific cookie. I don't see how this is done. Cookies are usually named by the domain. If I want to reference a specific cookie, do I...
0
385
by: Karl | last post by:
Hi everyone, We developped a WebService with Visual Studio .Net and we faced an authentication problem with a java client. My assumption is that this is because cookies passed from client are misunderstood by the framework. Basically, these are the headers received from the client (I used a packet sniffer to know exactly what we received from him before the framework modifies it):
6
7088
by: Jason Collins | last post by:
There seems to be an inconsistency (bug?) in the way the Set-Cookie header is handled by the WebHeaderCollection. That is, the values of Set-Cookie, when an Expires is specified, contain the "," character. This seems to be incorrectly parsed during GetValues(). A simple example shows it best (there are 2 .aspx pages and an output): AddHeaders.aspx: <%@ Page language="c#" %>
7
19087
by: itay_k | last post by:
Hi, I dont understand why this is so complicated, just to add one line of cookie header on the GET request. This is my unworking code: import time import Cookie import cookielib, urllib2
5
3166
by: cbhoem | last post by:
Hi - I am trying my hand at python cookies. I'm confused about a few things though. Do the python cookies get written to a cookies text file? I have simple code below -- I see the cookie in my HTTP header but do not get anything in the cookie text file. I'm working on linux. print "Content-type: text/html" cookie = Cookie.SimpleCookie()
5
2033
by: Mike C# | last post by:
Is there a decent cookie parser out there somewhere? I keep running into cookies that .NET can't handle. I've also found a couple of other parsers but they're choking as well.
0
9731
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10405
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.