Classic ASP -> Response.Cookies access
Steven Manross <[email protected]> Wed, 23 Oct 2024 23:42:21 +0000
| Newsgroups | gmane.comp.python.windows |
|---|---|
| Message-ID | <[email protected]> |
--===============2775760835099757882==
Content-Language: en-US
Content-Type: multipart/alternative;
boundary="_000_81a0ed7ca3594c419b5a93c6ee0f7d24manrossnet_"
--_000_81a0ed7ca3594c419b5a93c6ee0f7d24manrossnet_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
I'm not sure if this is implemented or not in the Python ASP code or not, b=
ut I am trying to duplicate some VBS code in Python, and use the URL below =
as a primer as I couldn't find any info on the internet about how Python mi=
ght implement this kind of ASP code.
I know the link is SUPER OLD but it's the best docs I have been able to fin=
d on the subject.
https://learn.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms524757(v=
=3Dvs.90)
I am trying to create cookies similar to how the Microsoft Certificate Auth=
ority Website on Windows Server 2016/2019/2022 does.
Here's my Python ASP code
<% @Language=3D"Python"%>
<%
Response.Write("Here<BR>")
for cookie in Response.Cookies:
Response.Write(Response.Cookies(cookie)["expires"])
Response.Write(f"dir =3D {Response.Cookies.__dir__()}")
if not "Type" in Response.Cookies:
cookie =3D Response.Cookies["type"] =3D "peanut-butter" # simplistic ex=
ample of trying to create one
Response.Write("Past Cookie Creation code<BR>")
%>
Here's my error:
Python ActiveX Scripting Engine error '80020009'
Traceback (most recent call last): File "<Script Block >", line 3, in <modu=
le> cookie =3D Response.Cookies["type"] =3D "peanut-butter" File "C:\Python=
310\lib\site-packages\win32com\client\dynamic.py", line 348, in __setitem__=
self._oleobj_.Invoke(*allArgs), self._olerepr_.defaultDispatchName, None C=
OM Error: OLE error 0x80020101
/testcookies.asp, line 5
cookie =3D Response.Cookies["type"] =3D "peanut-butter"
Any guidance would be appreciated as I've scoured google for all it was wor=
th.
If it helps.... The VBScript I'm trying to duplicate is:
# snippet of certsrck.inc from the "CertSRV" (MS Certificate Authority) web=
site.
Sub PutRequests(rgRequests)
Dim sCookie, sRequests, nIndex
sRequests=3D""
' check for the empty list
If IsNull(rgRequests) Then
' the list is empty
' do nothing
sRequests=3D"-" ' Lynx won't set an empty c=
ookie, so set an invalid one
Else
' the list is not empty
' build a string for each request and conca=
tenate to make cookie
For nIndex=3D0 To UBound(rgRequests)
sRequests=3DsRequests & "["=
& _
rgRequests(=
nIndex)(FIELD_REQID) & "," & _
rgRequests(=
nIndex)(FIELD_TARGETSTOREFLAGS) & "," & _
rgRequests(=
nIndex)(FIELD_SAVECERT) & "," & _
rgRequests(=
nIndex)(FIELD_FRIENDLYTYPE) & "]"
Next
End If
' Set the cookie
Response.Cookies(REQUEST_COOKIE_NAME)=3DsRequests
' Set the expiration date
Response.Cookies(REQUEST_COOKIE_NAME).Expires=3DNow+nPendin=
gTimeoutDays
' Set the path
Response.Cookies(REQUEST_COOKIE_NAME).Path=3D"/"
End Sub
Steven
--_000_81a0ed7ca3594c419b5a93c6ee0f7d24manrossnet_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ligatures:standardcontextual;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72" style=3D"word-wrap:=
break-word">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">I’m not sure if this is implemented or not in =
the Python ASP code or not, but I am trying to duplicate some VBS code in P=
ython, and use the URL below as a primer as I couldn’t find any info =
on the internet about how Python might implement
this kind of ASP code.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">I know the link is SUPER OLD but it’s the best=
docs I have been able to find on the subject.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><a href=3D"https://learn.microsoft.com/en-us/previou=
s-versions/iis/6.0-sdk/ms524757(v=3Dvs.90)">https://learn.microsoft.com/en-=
us/previous-versions/iis/6.0-sdk/ms524757(v=3Dvs.90)</a><o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">I am trying to create cookies similar to how the Mic=
rosoft Certificate Authority Website on Windows Server 2016/2019/2022 does.=
<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Here’s my Python ASP code<o:p></o:p></p>
<p class=3D"MsoNormal"><% @Language=3D"Python"%><o:p></o:p>=
</p>
<p class=3D"MsoNormal"><%<o:p></o:p></p>
<p class=3D"MsoNormal">Response.Write("Here<BR>")<o:p></o:p=
></p>
<p class=3D"MsoNormal">for cookie in Response.Cookies:<o:p></o:p></p>
<p class=3D"MsoNormal"> Response.Write(Response.Cookies(cookie=
)["expires"]) <o:p>
</o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Response.Write(f"dir =3D {Response.Cookies.__di=
r__()}")<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">if not "Type" in Response.Cookies:<o:p></o=
:p></p>
<p class=3D"MsoNormal"> cookie =3D Response.Cookies["type=
"] =3D "peanut-butter" # simplistic example of trying to cre=
ate one<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Response.Write("Past Cookie Creation code<BR=
>")<o:p></o:p></p>
<p class=3D"MsoNormal">%><o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Here’s my error:<br>
<br>
<o:p></o:p></p>
<p class=3D"MsoNormal">Python ActiveX Scripting Engine error '80020009=
'<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Traceback (most recent call last): File "<Sc=
ript Block >", line 3, in <module> cookie =3D Response.Cookie=
s["type"] =3D "peanut-butter" File "C:\Python310\l=
ib\site-packages\win32com\client\dynamic.py", line 348, in __setitem__=
self._oleobj_.Invoke(*allArgs),
self._olerepr_.defaultDispatchName, None COM Error: OLE error 0x80020101<o=
:p></o:p></p>
<p class=3D"MsoNormal">/testcookies.asp, line 5<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">cookie =3D Response.Cookies["type"] =3D &q=
uot;peanut-butter"<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Any guidance would be appreciated as I’ve scou=
red google for all it was worth.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">If it helps…. The VBScript I’m try=
ing to duplicate is:<br>
# snippet of certsrck.inc from the “CertSRV” (MS Certificate Au=
thority) website.<o:p></o:p></p>
<p class=3D"MsoNormal"><br>
Sub PutRequests(rgRequests)<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; Dim sCookie, sRequests, nIndex<o:p><=
/o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; sRequests=3D""<o:p></o:p><=
/p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; ' check for the empty list<o:p></o:p=
></p>
<p class=3D"MsoNormal"> &nbs=
p; If IsNull(rgRequests) Then<o:p></o:p=
></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; ' the list is e=
mpty<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; ' d=
o nothing<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; sRequests=3D&qu=
ot;-" ' Lynx won't set an empty cookie, so set an invalid one<o:p></o:=
p></p>
<p class=3D"MsoNormal"> &nbs=
p; Else<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; ' the list is n=
ot empty<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; ' build a strin=
g for each request and concatenate to make cookie<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; For nIndex=3D0 =
To UBound(rgRequests)<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; &nbs=
p; &=
nbsp; sRequests=3DsRequests & "[" & _<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; &nbs=
p; &=
nbsp; &nbs=
p; rgRequests(nIndex)(FIELD_REQID) & ",&qu=
ot; & _<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; &nbs=
p; &=
nbsp; &nbs=
p; rgRequests(nIndex)(FIELD_TARGETSTOREFLAGS) &=
"," & _<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; &nbs=
p; &=
nbsp; &nbs=
p; rgRequests(nIndex)(FIELD_SAVECERT) & ",=
" & _<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; &nbs=
p; &=
nbsp; &nbs=
p; rgRequests(nIndex)(FIELD_FRIENDLYTYPE) & &qu=
ot;]"<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; &=
nbsp; Next<o:p></o:p>=
</p>
<p class=3D"MsoNormal"> &nbs=
p; End If<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; ' Set the cookie<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; Response.Cookies(REQUEST_COOKIE_NAME=
)=3DsRequests<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; ' Set the expiration date<o:p></o:p>=
</p>
<p class=3D"MsoNormal"> &nbs=
p; Response.Cookies(REQUEST_COOKIE_NAME=
).Expires=3DNow+nPendingTimeoutDays<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; ' Set the path<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; Response.Cookies(REQUEST_COOKIE_NAME=
).Path=3D"/"<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">End Sub<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Steven<o:p></o:p></p>
</div>
</body>
</html>
--_000_81a0ed7ca3594c419b5a93c6ee0f7d24manrossnet_--
--===============2775760835099757882==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32
--===============2775760835099757882==--