Exception thrown when reading Base64 encoded RequestStream.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- backend, networking
Research direction
Start with the RequestStream class and reproduce the JavaScript FileReader upload, then read the request input through StreamReader.ReadToEnd to observe the byteCount exception. Compare the implementation with the linked Mono RequestStream.cs version, accounting for the changed property names. Done means the Base64-encoded request stream can be read without the exception.
Written by the indexing model from the issue text.
Description
Use javascript to upload an image using a FileReader. For example:
// Closure to capture the file information.
reader.onload = function (e) {
// Split by a comma to remove the url: prefix
var data = e.target.result.split(',')[1];
var url = self.getUrl("Users/" + userId + "/Images/" + imageType);
self.ajax({
type: "POST",
url: url,
data: data,
contentType: "image/" + file.name.substring(file.name.lastIndexOf('.') + 1)
});
};
// Read in the image file as a data URL.
reader.readAsDataURL(file);
Then on the server, attempt to read the input stream using StreamReader.ReadToEnd. The following exception will be thrown:
Non-negative number required.
Parameter name: byteCount
System.ArgumentOutOfRangeException
at System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex, Boolean flush)
at System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex)
at System.IO.StreamReader.<ReadBufferAsync>d__28.MoveNext()
FYI - this can be fixed by replacing the entire contents of the RequestStream class with the version from mono (and adjusting property names that have changed):
At the moment i do not have the time to hunt down the exact issue and submit a pull request, but i thought this information might be useful to you.
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sta/websocket-sharp
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
sta/websocket-sharp#201 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 45/100
sta/websocket-sharp#762 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
sta/websocket-sharp#761 ·
-
Bad handling of sending stream makes lib not RFC compatible and KeepClean useless in some cases. Open
Difficulty 4/5 3-5 days Newbie friendliness 42/100
sta/websocket-sharp#760 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sta/websocket-sharp#759 ·
All issues in sta/websocket-sharp
Similar issues
-
bug documentation frontend
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
azurenoops/spin_agent#975 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100