{"id":13431236,"url":"https://github.com/StefH/NETStandard.HttpListener","last_synced_at":"2025-03-16T11:31:20.198Z","repository":{"id":60774058,"uuid":"80154090","full_name":"StefH/NETStandard.HttpListener","owner":"StefH","description":"HttpListener for .NET Core (NETStandard 1.3) and Universal Windows Platform (UWP) ","archived":false,"fork":false,"pushed_at":"2018-02-24T08:09:57.000Z","size":286,"stargazers_count":40,"open_issues_count":1,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T19:43:16.795Z","etag":null,"topics":["http-listener","netstandard","uwp"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/StefH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-26T20:48:52.000Z","updated_at":"2023-11-22T09:11:00.000Z","dependencies_parsed_at":"2022-10-04T15:31:13.016Z","dependency_job_id":null,"html_url":"https://github.com/StefH/NETStandard.HttpListener","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/StefH%2FNETStandard.HttpListener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FNETStandard.HttpListener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FNETStandard.HttpListener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FNETStandard.HttpListener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StefH","download_url":"https://codeload.github.com/StefH/NETStandard.HttpListener/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243668032,"owners_count":20328039,"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":["http-listener","netstandard","uwp"],"created_at":"2024-07-31T02:01:01.556Z","updated_at":"2025-03-16T11:31:20.169Z","avatar_url":"https://github.com/StefH.png","language":"HTML","readme":"# NETStandard.HttpListener .NETStandard 1.3 and UWP\nA simple library based on (https://github.com/robertsundstrom/HttpListener) that essentially allows for building your own HTTP server on .NETStandard 1.3 and the Universal Windows Platform (UWP).\n\n[![Build status](https://ci.appveyor.com/api/projects/status/192if73p5og2o2yq?svg=true)](https://ci.appveyor.com/project/StefH/netstandard-httplistener)\n[![codecov](https://codecov.io/gh/StefH/NETStandard.HttpListener/branch/master/graph/badge.svg)](https://codecov.io/gh/StefH/NETStandard.HttpListener)\n[![Coverage Status](https://coveralls.io/repos/github/StefH/NETStandard.HttpListener/badge.svg?branch=master)](https://coveralls.io/github/StefH/NETStandard.HttpListener?branch=master)\n[![NuGet Badge](https://buildstats.info/nuget/NETStandard.HttpListener)](https://www.nuget.org/packages/NETStandard.HttpListener)\n\n## Overview\n\nThis library fills the void left by the missing System.Net.Http.HttpListener in .NET Core and Universal Windows Platform (UWP).\n\nBy targetting NETStandard 1.3 and UWP (10.0.10240.0), this API enables HTTP server scenarios on Windows 10 for IoT on Raspberry Pi (2 \u0026 3).\n\nTaking a modern approach, this API is not meant to be entirely compatible with the HttpListener found in the full .NET Framework on Windows desktop.\n\nPlease, be aware that this is an early concept, and thus not ready for production.\n\nContributions are most welcome.\n\n## Solution\n\nThe solution consists of two projects with a common core targetting:\n\n1. .NET Core 1.1 project - Windows, Linux and Mac OS X.\n2. Universal Windows Platform (UWP) - Windows 10 and up. (10.0.10240.0)\n\nThe API:s are generally similar, but may differ slightly on each platform due to their respective API constraints. However, the core concepts remain the same.\n\nOn .NET Core it uses .NET's TCPListener and TCPClient.\n\nOn UWP it uses Windows Runtime's StreamSocketListener and StreamSocket.\n\n## Sample\nAdd the using statements.\n\n```CSharp\nusing System;\nusing System.Net;\nusing System.Net.Http;\n```\n\nThe code used in this sample should be the same on any platform.\n\n``` CSharp\nvar listener = new HttpListener(IPAddress.Parse(\"127.0.0.1\"), 8081);\ntry\n{\n\tlistener.Request += async (sender, context) =\u003e\n\t{\n\t\tvar request = context.Request;\n\t\tvar response = context.Response;\n\t\tif (request.HttpMethod == HttpMethods.Get)\n\t\t{\n\t\t\tawait response.WriteContentAsync($\"Hello from Server at: {DateTime.Now}\\r\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tresponse.MethodNotAllowed();\n\t\t}\n\t\t// Close the HttpResponse to send it back to the client.\n\t\tresponse.Close();\n\t};\n\tlistener.Start();\n\n\tConsole.WriteLine(\"Press any key to exit.\");\n\tConsole.ReadKey();\n}\ncatch (Exception exc)\n{\n\tConsole.WriteLine(exc.ToString());\n}\nfinally\n{\n\tlistener.Close();\n}\n```\n\nVisit 127.0.0.1:8081 in your browser.\n\nAlso consider having a look at the unit tests.\n\n\n## Todo\nHere are some things to consider doing in the future:\n\n* Rewrite the HttpRequest parser and implement missing features, like authentication and the handling of content types.\n","funding_links":[],"categories":["Frameworks, Libraries and Tools","框架, 库和工具","Networking"],"sub_categories":["Networking","网络"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStefH%2FNETStandard.HttpListener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FStefH%2FNETStandard.HttpListener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStefH%2FNETStandard.HttpListener/lists"}