{"action":"opened","issue":{"url":"https://api.github.com/repos/tibel/Kinda.Licensing/issues/9","repository_url":"https://api.github.com/repos/tibel/Kinda.Licensing","labels_url":"https://api.github.com/repos/tibel/Kinda.Licensing/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/tibel/Kinda.Licensing/issues/9/comments","events_url":"https://api.github.com/repos/tibel/Kinda.Licensing/issues/9/events","html_url":"https://github.com/tibel/Kinda.Licensing/issues/9","id":190561971,"number":9,"title":"htpdate","user":{"login":"tibel","id":387395,"avatar_url":"https://avatars.githubusercontent.com/u/387395?v=3","gravatar_id":"","url":"https://api.github.com/users/tibel","html_url":"https://github.com/tibel","followers_url":"https://api.github.com/users/tibel/followers","following_url":"https://api.github.com/users/tibel/following{/other_user}","gists_url":"https://api.github.com/users/tibel/gists{/gist_id}","starred_url":"https://api.github.com/users/tibel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tibel/subscriptions","organizations_url":"https://api.github.com/users/tibel/orgs","repos_url":"https://api.github.com/users/tibel/repos","events_url":"https://api.github.com/users/tibel/events{/privacy}","received_events_url":"https://api.github.com/users/tibel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-20T14:44:21Z","updated_at":"2016-11-20T14:44:21Z","closed_at":null,"body":"``` csharp\r\n        static void Main(string[] args)\r\n        {\r\n            //Don't use SNTP/NTP as it is insecure and does not support proxys\r\n\r\n            var time = GetTimeFromHttpHeader(\"https://www.google.com\");\r\n            Console.WriteLine(time);\r\n\r\n            Console.ReadKey();\r\n        }\r\n\r\n        private static DateTime GetTimeFromHttpHeader(string uri)\r\n        {\r\n            var request = (HttpWebRequest)WebRequest.Create(uri);\r\n            request.KeepAlive = false;\r\n            request.Timeout = 1000;\r\n\r\n            using (var response = (HttpWebResponse)request.GetResponse())\r\n            {\r\n                if (response.StatusCode != HttpStatusCode.OK)\r\n                    return DateTime.MinValue;\r\n\r\n                var date = response.GetResponseHeader(\"Date\");\r\n                return DateTime.ParseExact(date, \"r\", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);\r\n            }\r\n        }\r\n```"}}
{"actor":{"display_login":"tibel"}}