-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: HttpListenerRequest.get_Form/FormData ( Fixes #1121 )
- Loading branch information
James Brundage
committed
May 4, 2024
1 parent
2dfcaf0
commit b1fda4d
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<# | ||
.SYNOPSIS | ||
Get the form data. | ||
.DESCRIPTION | ||
Get the form data from the request. | ||
.OUTPUTS | ||
[Ordered] | ||
.NOTES | ||
If the content type was not application/x-www-form-urlencoded, this will return an empty dictionary. | ||
If there was no request body, this will return an empty dictionary. | ||
If the request body is not already cached, it will be parsed and cached. | ||
#> | ||
param() | ||
if ($this.'.CachedFormData') { return $this.'.CachedFormData' } | ||
$cachedFormData = [Ordered]@{} | ||
if ($this.ContentType -match 'application/x-www-form-urlencoded' -and $this.Body) { | ||
$parsedFormData = [Web.HttpUtility]::ParseQueryString($this.Body) | ||
foreach ($key in $parsedFormData.Keys) { | ||
$cachedFormData[$key] = $parsedFormData[$key] | ||
} | ||
} | ||
$this.psobject.properties.add(( | ||
[psnoteproperty]::new('.CachedFormData', $cachedFormData) | ||
), $true) | ||
return $cachedFormData | ||
|
||
|
||
|