{"id":125,"date":"2006-04-25T20:27:31","date_gmt":"2006-04-26T01:27:31","guid":{"rendered":"http:\/\/bitpost.com\/news\/2006\/04\/25\/microsofts-shoddy-http-api\/"},"modified":"2006-05-04T15:12:53","modified_gmt":"2006-05-04T20:12:53","slug":"microsofts-shoddy-http-api","status":"publish","type":"post","link":"https:\/\/bitpost.com\/news\/2006\/microsofts-shoddy-http-api\/","title":{"rendered":"Microsoft&#8217;s shoddy HTTP API"},"content":{"rendered":"<p>What&#8217;s the FIRST thing you&#8217;re going to want to add after you figure out how to programatically request web pages through Microsoft&#8217;s WinINet HTTP API? Perhaps add a timeout? Forget it.<\/p>\n<p><strong>UPDATE<\/strong>: Even with my snotty tone, I still got some great feedback from someone at Microsoft, Ari Pernick, about the state of things &#8211; see the comments. Thanks Ari!<\/p>\n<p><!--more-->From <a href=\"http:\/\/support.microsoft.com\/kb\/q176420\/\">MSDN<\/a>:<\/p>\n<blockquote><p><strong>SYMPTOMS<\/strong><br \/>\nCalling InternetSetOption (or MFC CHttpFile::SetOption) with INTERNET_OPTION_SEND_TIMEOUT or INTERNET_OPTION_CONNECT_TIMEOUT does not set the specified timeout values.<\/p>\n<p><strong>RESOLUTION<\/strong><br \/>\nTo work around the problem you can use asynchronous WinInet mode, which prevents the WinInet function call from blocking while waiting for a connection. Please see the Internet Client SDK documentation for more information about using WinInet asynchronously.<\/p><\/blockquote>\n<p>As if it weren&#8217;t hard enough to set up the synchronous HTTP connection&#8230; I already did the threading for it, all I wanted was a timeout. And when they say &#8220;for more information&#8221;, don&#8217;t think they mean all of it. I&#8217;ve seen the word &#8220;nightmare&#8221; used to describe it more than once. There are attempts at this on CodeProject <a href=\"http:\/\/www.codeproject.com\/internet\/asyncwininet.asp\">here<\/a> and <a href=\"http:\/\/www.codeproject.com\/internet\/w3client.asp\">here<\/a>, but nothing too straightforward.  There is <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/wininet\/wininet\/calling_wininet_functions_asynchronously.asp\">documentation<\/a> in MSDN, and a <a href=\"http:\/\/support.microsoft.com\/default.aspx?scid=kb;EN-US;275046\">sample<\/a>, time to dig in&#8230;<\/p>\n<p>Looks like there is a newer <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/winhttp\/http\/about_winhttp.asp\">WinHTTP API<\/a>, with an <a href=\"http:\/\/www.codeproject.com\/internet\/webcrawler.asp\">example<\/a> on CodeProject. But no multipart form post, reduced cookie and cache handling, incompatible with anything pre-Windows XP (you can use Win2k with the 5.0 release, which Microsoft has purged from MSDN), etc&#8230; and still, it&#8217;s overly complex with shoddy docs&#8230;  I love that word, &#8220;shoddy&#8221;, and I got to use it twice today!<\/p>\n<p>While we&#8217;re at it, check out the kludgy way Microsoft has you deal with <a href=\"http:\/\/support.microsoft.com\/kb\/q182888\/\">invalid SSL certificates<\/a> (I guess they think that never happens when you use REAL &#8220;vendors&#8221;).  Bonus: includes &#8220;goto&#8221; statements!!<\/p>\n<p>I guess Microsoft has moved on, to working on the C# interfaces&#8230; I yearn for the beauty of perl&#8217;s WWW::Mechanize&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What&#8217;s the FIRST thing you&#8217;re going to want to add after you figure out how to programatically request web pages through Microsoft&#8217;s WinINet HTTP API? Perhaps add a timeout? Forget it. UPDATE: Even with my snotty tone, I still got some great feedback from someone at Microsoft, Ari Pernick, about the state of things &#8211; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[10],"tags":[],"class_list":["post-125","post","type-post","status-publish","format-standard","hentry","category-tricks-tips-tools"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9M11L-21","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/comments?post=125"}],"version-history":[{"count":0,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/125\/revisions"}],"wp:attachment":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/media?parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/categories?post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/tags?post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}