Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Products
/
VSTT-Plugins
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
2
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
80f74fe6
...
80f74fe6245b3fe3728a74305a72ac98d1452c6b
authored
2019-10-18 21:02:54 +0200
by
Christian Gerdes
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
New WebTest Plugin: "Force UrlEncoded Cookies"
1 parent
70840838
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
LIL_VSTT_Plugins/Beta.cs
LIL_VSTT_Plugins/Beta.cs
View file @
80f74fe
...
...
@@ -20,9 +20,42 @@ using System.Text.RegularExpressions;
using
System.IO
;
using
System.IO.Compression
;
using
Microsoft.VisualStudio.TestTools.LoadTesting
;
using
System.Net
;
namespace
LIL_VSTT_Plugins
{
[
DisplayName
(
"Force UrlEncoded Cookies"
)]
[
Description
(
"Reparses all cookies set by the server and stores the value in UrlEncoded format. Cookies with illegal characters will otherwise cause none of the previous set cookies to be added to new requests."
)]
public
class
DebugCookies
:
WebTestPlugin
{
public
override
void
PostRequest
(
object
sender
,
PostRequestEventArgs
e
)
{
if
(
e
.
ResponseExists
)
{
for
(
int
i
=
0
;
i
<
e
.
Response
.
Headers
.
Count
;
i
++)
{
if
(
e
.
Response
.
Headers
.
Keys
[
i
].
Equals
(
"Set-Cookie"
))
{
try
{
System
.
Net
.
CookieContainer
cc
=
new
System
.
Net
.
CookieContainer
();
cc
.
SetCookies
(
e
.
Response
.
ResponseUri
,
e
.
Response
.
Headers
[
i
]);
foreach
(
Cookie
c
in
cc
.
GetCookies
(
e
.
Response
.
ResponseUri
))
{
c
.
Value
=
WebUtility
.
UrlEncode
(
WebUtility
.
UrlDecode
(
c
.
Value
));
e
.
WebTest
.
Context
.
CookieContainer
.
Add
(
c
);
}
}
catch
(
Exception
ex
)
{
e
.
WebTest
.
AddCommentToResult
(
"Set-Cookie: Exception: "
+
ex
.
Message
);
}
}
}
}
}
}
[
DisplayName
(
"Add Session Cookie"
)]
[
Description
(
"Adds a cookie to the webtest cookie collection for this request and all remaining requests in this session."
)]
public
class
AddSessionCookie
:
WebTestRequestPlugin
...
...
Please
register
or
sign in
to post a comment