{"id":22835194,"url":"https://github.com/jchristn/chunkdecoder","last_synced_at":"2025-04-24T00:07:36.455Z","repository":{"id":65413721,"uuid":"193294434","full_name":"jchristn/ChunkDecoder","owner":"jchristn","description":"Library for decoding chunk-transfer-encoded data, particularly from HTTP.","archived":false,"fork":false,"pushed_at":"2022-01-07T16:01:41.000Z","size":261,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T00:07:29.124Z","etag":null,"topics":["chunk","chunk-data","decoder","http","http-server","https","https-server","nuget","server","web"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jchristn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["jchristn"],"custom":["https://paypal.me/joelchristner"]}},"created_at":"2019-06-23T01:30:27.000Z","updated_at":"2023-11-27T01:04:00.000Z","dependencies_parsed_at":"2023-01-22T09:35:11.766Z","dependency_job_id":null,"html_url":"https://github.com/jchristn/ChunkDecoder","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FChunkDecoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FChunkDecoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FChunkDecoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FChunkDecoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jchristn","download_url":"https://codeload.github.com/jchristn/ChunkDecoder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535099,"owners_count":21446508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chunk","chunk-data","decoder","http","http-server","https","https-server","nuget","server","web"],"created_at":"2024-12-12T22:08:39.590Z","updated_at":"2025-04-24T00:07:36.420Z","avatar_url":"https://github.com/jchristn.png","language":"C#","readme":"![alt tag](https://github.com/jchristn/chunkdecoder/blob/master/assets/icon.ico)\n\n# ChunkDecoder \n\n[![NuGet Version](https://img.shields.io/nuget/v/ChunkDecoder.svg?style=flat)](https://www.nuget.org/packages/ChunkDecoder/) [![NuGet](https://img.shields.io/nuget/dt/ChunkDecoder.svg)](https://www.nuget.org/packages/ChunkDecoder) \n\nChunkDecoder is useful to help decode chunk-transfer-encoded data, particularly from HTTP.\n\n## New in v1.0.4\n\n- XML documentation\n\n## Usage\n```csharp\nusing ChunkDecoder;\n\npublic Decoder decoder = new Decoder();\n\n// process a byte array\nif (decoder.Decode(data, out outData))\n{\n  // success\n}\n\n// process a stream\nlong outLength = 0;\nMemoryStream outStream = null;\nif (decoder.Decode(stream, out outLength, out outStream))\n{\n  // success\n}\n```\n\n## Functionality\n\nChunk-transfer-encoded data is sent in segments, where each segment is comprised of a line containing the length (in hexadecimal) and the subsequent line containing the payload.  Each line ends with a carriage return and line feed \u003ccrlf\u003e.\n\nThe final line ends with ```0\u003ccrlf\u003e\u003ccrlf\u003e``` indicating the end of the stream.\n\nFor instance:\n```\n6\u003ccrlf\u003e        // 6 bytes of data will follow.\nHello_\u003ccrlf\u003e   // data.  The value is 'Hello_' where _ is actually a space.\n5\u003ccrlf\u003e        // 5 bytes of data will follow.\nWorld\u003ccrlf\u003e    // data.  The value is 'World'.\n0\u003ccrlf\u003e\u003ccrlf\u003e  // end of stream.\n```\nResults in:\n```\nHello world\n```\n\nFor more information, please see: \n\n- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding\n- https://en.wikipedia.org/wiki/Chunked_transfer_encoding\n\n## Callbacks\n\nIn cases where the supplied data has signatures, i.e.\n```\n6;chunk-signature=foo\u003ccrlf\u003e  // 6 bytes of data will follow, and the signature of the chunk is foo.\nHello_\u003ccrlf\u003e                 // data.  The value is 'Hello ' and _ is actually a space.\n5;chunk-signature:bar\u003ccrlf\u003e  // 5 bytes of data will follow, and the signature of the chunk is bar.\nWorld\u003ccrlf\u003e                  // data.  The value is 'World'.\n0;\u003ccrlf\u003e\u003ccrlf\u003e               // end of stream.\n```\n\nYou can assigned the ```Decoder.ProcessSignature``` callback, which has the following signature:\n```csharp\nusing System.Collections.Generic;\n\nstatic bool ProcessSignature(KeyValuePair\u003cstring, string\u003e, byte[] data)\n{\n\treturn true;\n}\n```\n\nThis method should return ```true```, otherwise ChunkDecoder will assume there is an error and terminate.\n\nIf you wish to process each chunk as it is read, set the ```Decoder.ProcessChunk``` callback, which has the followning signature:\n```csharp\nstatic bool ProcessChunk(byte[] data)\n{\n\treturn true;\n}\n```\n\nThis method should also return ```true```, for the same reason.  ProcessChunk is always called after ProcessSignature.\n\n## Version History\n\nRefer to CHANGELOG.md\n","funding_links":["https://github.com/sponsors/jchristn","https://paypal.me/joelchristner"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchristn%2Fchunkdecoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjchristn%2Fchunkdecoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchristn%2Fchunkdecoder/lists"}