├── .gitmodules
├── component
├── .gitignore
├── icon_128x128.png
├── icon_512x512.png
├── xamarin-component.exe
├── GettingStarted.md
├── Details.md
├── component.yaml
├── License.md
└── Makefile
├── .gitignore
├── vendor
└── nuget
│ ├── NuGet.exe
│ ├── NuGet.Config
│ └── NuGet.targets
├── ext
├── monotouch
│ └── Newtonsoft.Json.dll
└── portable-headers
│ └── System.Net.Http.dll
├── samples
├── HttpClient.iOS
│ ├── Resources
│ │ ├── Default.png
│ │ ├── icon-29.png
│ │ ├── icon-50.png
│ │ ├── icon-57.png
│ │ ├── icon-58.png
│ │ ├── icon-72.png
│ │ ├── icon-100.png
│ │ ├── icon-114.png
│ │ ├── icon-144.png
│ │ ├── Default@2x.png
│ │ ├── iTunesArtwork.png
│ │ ├── Default-568h@2x.png
│ │ ├── iTunesArtwork@2x.png
│ │ ├── Default-Landscape~ipad.png
│ │ ├── Default-Portrait~ipad.png
│ │ ├── Default-Portrait@2x~ipad.png
│ │ └── Default-Landscape@2x~ipad.png
│ ├── Screenshots
│ │ └── HttpClient.jpg
│ ├── README.md
│ ├── Metadata.xml
│ ├── NetHttp.cs
│ ├── DotNet.cs
│ ├── HttpClient.iOS.sln
│ ├── Info.plist
│ ├── MainWindow.xib.designer.cs
│ ├── TableViewRocks.cs
│ ├── Main.cs
│ ├── HttpClient.csproj
│ └── MainWindow.xib
└── HttpClient.Android
│ ├── Resources
│ ├── drawable
│ │ └── Icon.png
│ ├── values
│ │ └── Strings.xml
│ ├── layout
│ │ ├── ShowStream.axml
│ │ └── Main.axml
│ ├── AboutResources.txt
│ └── Resource.designer.cs
│ ├── packages.config
│ ├── Properties
│ ├── AndroidManifest.xml
│ └── AssemblyInfo.cs
│ ├── Assets
│ └── AboutAssets.txt
│ ├── ShowStream.cs
│ ├── NetHttp.cs
│ ├── HttpClient.Android.sln
│ ├── DotNet.cs
│ ├── MainActivity.cs
│ └── HttpClient.Android.csproj
├── src
├── Playground.Android
│ ├── Resources
│ │ ├── drawable
│ │ │ └── Icon.png
│ │ ├── values
│ │ │ └── Strings.xml
│ │ ├── layout
│ │ │ └── Main.axml
│ │ ├── AboutResources.txt
│ │ └── Resource.designer.cs
│ ├── packages.config
│ ├── Properties
│ │ ├── AndroidManifest.xml
│ │ └── AssemblyInfo.cs
│ ├── Assets
│ │ └── AboutAssets.txt
│ ├── Playground.Android.csproj
│ └── MainActivity.cs
├── ModernHttpClient
│ ├── Resources
│ │ ├── values
│ │ │ └── Strings.xml
│ │ ├── Resource.designer.cs
│ │ └── AboutResources.txt
│ ├── packages.config
│ ├── CaptiveNetworkException.cs
│ ├── iOS
│ │ ├── NativeCookieHandler.cs
│ │ ├── AsyncLock.cs
│ │ ├── NSErrorExtended.cs
│ │ └── CFNetworkErrors.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Android
│ │ ├── NativeCookieHandler.cs
│ │ ├── ConcatenatingStream.cs
│ │ └── OkHttpNetworkHandler.cs
│ ├── Utility.cs
│ ├── ModernHttpClient.Portable.csproj
│ ├── ModernHttpClient.iOS64.csproj
│ ├── Facades.cs
│ ├── ModernHttpClient.iOS.csproj
│ ├── ModernHttpClient.Android.csproj
│ └── ProgressStreamContent.cs
└── Playground.iOS
│ ├── Entitlements.plist
│ ├── Main.cs
│ ├── Info.plist
│ ├── Playground_iOSViewController.designer.cs
│ ├── AppDelegate.cs
│ ├── Playground_iOSViewController.xib
│ ├── Playground_iOSViewController.cs
│ └── Playground.iOS.csproj
├── COPYING
├── ModernHttpClient.nuspec
├── README.md
├── Makefile
├── CODE_OF_CONDUCT.md
└── ModernHttpClient.sln
/.gitmodules:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/component/.gitignore:
--------------------------------------------------------------------------------
1 | *.xam
2 |
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | bin/
3 | obj/
4 | build/
5 | *.userprefs
6 | build/
7 | *.xam
8 | packages
9 |
--------------------------------------------------------------------------------
/vendor/nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/vendor/nuget/NuGet.exe
--------------------------------------------------------------------------------
/component/icon_128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/component/icon_128x128.png
--------------------------------------------------------------------------------
/component/icon_512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/component/icon_512x512.png
--------------------------------------------------------------------------------
/component/xamarin-component.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/component/xamarin-component.exe
--------------------------------------------------------------------------------
/ext/monotouch/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/ext/monotouch/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/ext/portable-headers/System.Net.Http.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/ext/portable-headers/System.Net.Http.dll
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/Default.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/icon-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/icon-29.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/icon-50.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/icon-57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/icon-57.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/icon-58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/icon-58.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/icon-72.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/icon-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/icon-100.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/icon-114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/icon-114.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/icon-144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/icon-144.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/Default@2x.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Screenshots/HttpClient.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Screenshots/HttpClient.jpg
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/iTunesArtwork.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/iTunesArtwork.png
--------------------------------------------------------------------------------
/src/Playground.Android/Resources/drawable/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/src/Playground.Android/Resources/drawable/Icon.png
--------------------------------------------------------------------------------
/samples/HttpClient.Android/Resources/drawable/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.Android/Resources/drawable/Icon.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/Default-568h@2x.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/iTunesArtwork@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/iTunesArtwork@2x.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/Default-Landscape~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/Default-Landscape~ipad.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/Default-Portrait~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/Default-Portrait~ipad.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/Default-Portrait@2x~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/Default-Portrait@2x~ipad.png
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Resources/Default-Landscape@2x~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/ModernHttpClient/HEAD/samples/HttpClient.iOS/Resources/Default-Landscape@2x~ipad.png
--------------------------------------------------------------------------------
/src/ModernHttpClient/Resources/values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ModernHttpClient.Android
4 |
5 |
--------------------------------------------------------------------------------
/vendor/nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/Playground.Android/Resources/values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Download some stuff
4 | Playground.Android
5 |
--------------------------------------------------------------------------------
/src/Playground.iOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/README.md:
--------------------------------------------------------------------------------
1 | HTTP Client
2 | ===========
3 |
4 | An example on using both the .NET and Objective-C classes to
5 | send a web request in one MonoTouch application.
6 |
7 |
8 | Authors
9 | -------
10 |
11 | Miguel de Icaza
12 |
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | d01773c4-0073-4ca2-852f-2c2781f12484
4 | false
5 | Beginning
6 | Web
7 |
8 |
--------------------------------------------------------------------------------
/src/ModernHttpClient/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/Playground.Android/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/component/GettingStarted.md:
--------------------------------------------------------------------------------
1 | The good news is, you don't have to know either of these two libraries above,
2 | using ModernHttpClient is the most boring thing in the world. Here's how it
3 | works:
4 |
5 | ```csharp
6 | var httpClient = new HttpClient(new NativeMessageHandler());
7 | ```
8 |
9 | ## Other Resources
10 |
11 | * [GitHub page](https://github.com/paulcbetts/ModernHttpClient)
12 | * [OkHttp site](http://square.github.io/okhttp/)
13 |
--------------------------------------------------------------------------------
/src/Playground.Android/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/Playground.iOS/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Foundation;
5 | using UIKit;
6 |
7 | namespace Playground.iOS
8 | {
9 | public class Application
10 | {
11 | // This is the main entry point of the application.
12 | static void Main (string[] args)
13 | {
14 | // if you want to use a different Application Delegate class from "AppDelegate"
15 | // you can specify it here.
16 | UIApplication.Main (args, null, "AppDelegate");
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/Resources/values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | HTTP Client Sample
4 | Select API:
5 | WebRequest
6 | HttpClient
7 | HttpClient/OkHttp
8 | Issue HTTP Request
9 | The HTML returned by the server:
10 | No data.
11 | Retrieving data...
12 |
13 |
--------------------------------------------------------------------------------
/component/Details.md:
--------------------------------------------------------------------------------
1 | This library brings the latest platform-specific networking libraries to Xamarin applications via a custom HttpClient handler. Write your app using System.Net.Http, but drop this library in and it will go drastically faster. This is made possible by two native libraries:
2 |
3 | * On iOS, via NSURLSession
4 | * On Android, via [OkHttp 1.5](http://square.github.io/okhttp/)
5 |
6 | ## Usage
7 |
8 | The good news is, you don't have to know either of these two libraries above,
9 | using ModernHttpClient is the most boring thing in the world. Here's how it
10 | works:
11 |
12 | ```csharp
13 | var httpClient = new HttpClient(new NativeMessageHandler());
14 | ```
15 |
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/NetHttp.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file contains the sample code to use System.Net.HttpClient
3 | // on the iPhone to communicate using Apple's CFNetwork API
4 | //
5 |
6 | using System;
7 | using System.Threading.Tasks;
8 | using System.Net.Http;
9 |
10 | namespace HttpClient
11 | {
12 | public class NetHttp
13 | {
14 | AppDelegate ad;
15 |
16 | public NetHttp (AppDelegate ad)
17 | {
18 | this.ad = ad;
19 | }
20 |
21 | public async Task HttpSample (HttpMessageHandler handler)
22 | {
23 | var client = new System.Net.Http.HttpClient (handler);
24 | ad.RenderStream (await client.GetStreamAsync (Application.WisdomUrl));
25 | }
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/src/Playground.Android/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with your package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with your package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/src/Playground.iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDisplayName
6 | Playground.iOS
7 | CFBundleIdentifier
8 | com.your-company.Playground.iOS
9 | UIDeviceFamily
10 |
11 | 1
12 |
13 | UISupportedInterfaceOrientations
14 |
15 | UIInterfaceOrientationPortrait
16 | UIInterfaceOrientationLandscapeLeft
17 | UIInterfaceOrientationLandscapeRight
18 |
19 | MinimumOSVersion
20 | 6.0
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/ShowStream.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Android.App;
6 | using Android.Content;
7 | using Android.OS;
8 | using Android.Runtime;
9 | using Android.Views;
10 | using Android.Widget;
11 |
12 | namespace HttpClient.Android
13 | {
14 | [Activity (Label = "Resulting Stream")]
15 | public class ShowStream : Activity
16 | {
17 | protected override void OnCreate (Bundle bundle)
18 | {
19 | base.OnCreate (bundle);
20 |
21 | SetContentView (Resource.Layout.ShowStream);
22 |
23 | var textview = FindViewById (Resource.Id.html_textView);
24 | textview.Text = this.Intent.GetStringExtra ("string") ?? Resources.GetString (Resource.String.no_data);
25 | }
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/NetHttp.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file contains the sample code to use System.Net.HttpClient
3 | // on the iPhone to communicate using Apple's CFNetwork API
4 | //
5 |
6 | using System;
7 | using System.Threading.Tasks;
8 | using System.Net.Http;
9 |
10 | namespace HttpClient.Android
11 | {
12 | public class NetHttp
13 | {
14 | MainActivity ad;
15 |
16 | public NetHttp (MainActivity ad)
17 | {
18 | this.ad = ad;
19 | }
20 |
21 | public async Task HttpSample (HttpMessageHandler handler = null)
22 | {
23 | this.ad.Busy ();
24 | System.Net.Http.HttpClient client = (handler == null) ?
25 | new System.Net.Http.HttpClient () :
26 | new System.Net.Http.HttpClient (handler);
27 | var stream = await client.GetStreamAsync (MainActivity.WisdomUrl);
28 | this.ad.Done ();
29 | ad.RenderStream (stream);
30 | }
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/HttpClient.Android.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient.Android", "HttpClient.Android.csproj", "{5A57599D-D355-47EF-B662-DED809E4A1BB}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {5A57599D-D355-47EF-B662-DED809E4A1BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {5A57599D-D355-47EF-B662-DED809E4A1BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {5A57599D-D355-47EF-B662-DED809E4A1BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {5A57599D-D355-47EF-B662-DED809E4A1BB}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(MonoDevelopProperties) = preSolution
18 | StartupItem = HttpClient.Android.csproj
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/Resources/layout/ShowStream.axml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
13 |
24 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using Android.App;
4 |
5 | // Information about this assembly is defined by the following attributes.
6 | // Change them to the values specific to your project.
7 | [assembly: AssemblyTitle ("HttpClient.Android")]
8 | [assembly: AssemblyDescription ("")]
9 | [assembly: AssemblyConfiguration ("")]
10 | [assembly: AssemblyCompany ("")]
11 | [assembly: AssemblyProduct ("")]
12 | [assembly: AssemblyTrademark ("")]
13 | [assembly: AssemblyCulture ("")]
14 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
15 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
16 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
17 | [assembly: AssemblyVersion ("1.0.0")]
18 | // The following attributes are used to specify the signing key for the assembly,
19 | // if desired. See the Mono documentation for more information about signing.
20 | //[assembly: AssemblyDelaySign(false)]
21 | //[assembly: AssemblyKeyFile("")]
22 |
23 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Paul Betts
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the "Software"), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7 | the Software, and to permit persons to whom the Software is furnished to do so,
8 | subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 |
--------------------------------------------------------------------------------
/src/Playground.Android/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using Android.App;
4 |
5 | // Information about this assembly is defined by the following attributes.
6 | // Change them to the values specific to your project.
7 | [assembly: AssemblyTitle ("Playground.Android")]
8 | [assembly: AssemblyDescription ("")]
9 | [assembly: AssemblyConfiguration ("")]
10 | [assembly: AssemblyCompany ("")]
11 | [assembly: AssemblyProduct ("")]
12 | [assembly: AssemblyCopyright ("paul")]
13 | [assembly: AssemblyTrademark ("")]
14 | [assembly: AssemblyCulture ("")]
15 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
16 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
17 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
18 | [assembly: AssemblyVersion ("1.0.0")]
19 | // The following attributes are used to specify the signing key for the assembly,
20 | // if desired. See the Mono documentation for more information about signing.
21 | //[assembly: AssemblyDelaySign(false)]
22 | //[assembly: AssemblyKeyFile("")]
23 |
24 |
--------------------------------------------------------------------------------
/component/component.yaml:
--------------------------------------------------------------------------------
1 | %YAML 1.2
2 | ---
3 | name: ModernHttpClient
4 | version: 2.4.2
5 | id: "modernhttpclient"
6 | publisher: Paul Betts
7 | publisher-url: http://blog.paulbetts.org/
8 | summary: Write your app using System.Net.Http, but drop this library in and it will go drastically faster.
9 | license: License.md
10 | details: Details.md
11 | getting-started: GettingStarted.md
12 | icons:
13 | - icon_128x128.png
14 | - icon_512x512.png
15 | libraries:
16 | ios:
17 | - ../build/MonoTouch/ModernHttpClient.dll
18 | ios-unified:
19 | - ../build/Xamarin.iOS10/ModernHttpClient.dll
20 | android:
21 | - ../build/MonoAndroid/ModernHttpClient.dll
22 | is_shell: true
23 | packages:
24 | android:
25 | - Square.OkHttp, Version=2.4.0.3
26 | - modernhttpclient, Version=2.4.2
27 | ios:
28 | - modernhttpclient, Version=2.4.2
29 | ios-unified:
30 | - modernhttpclient, Version=2.4.2
31 | samples:
32 | - name: "HttpClient.iOS Unified API Sample"
33 | path: ../samples/HttpClient.iOS/HttpClient.iOS.sln
34 | - name: "HttpClient.Android Sample"
35 | path: ../samples/HttpClient.Android/HttpClient.Android.sln
36 | ...
37 |
--------------------------------------------------------------------------------
/ModernHttpClient.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2.4.2
5 | Paul Betts
6 | Paul Betts
7 | https://github.com/paulcbetts/ModernHttpClient/blob/master/COPYING
8 | https://github.com/paulcbetts/ModernHttpClient
9 | modernhttpclient
10 | ModernHttpClient
11 | false
12 | Write your app using System.Net.Http, but drop this library in and it will go drastically faster.
13 | Write your app using System.Net.Http, but drop this library in and it will go drastically faster.
14 | Copyright Paul Betts © 2012
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ModernHttpClient
2 | ================
3 |
4 | This library brings the latest platform-specific networking libraries to
5 | Xamarin applications via a custom HttpClient handler. Write your app using
6 | System.Net.Http, but drop this library in and it will go drastically faster.
7 | This is made possible by two native libraries:
8 |
9 | * On iOS, [NSURLSession](https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSession_class/Introduction/Introduction.html)
10 | * On Android, via [OkHttp](http://square.github.io/okhttp/)
11 |
12 | ## Usage
13 |
14 | The good news is, you don't have to know either of these two libraries above,
15 | using ModernHttpClient is the most boring thing in the world. Here's how
16 | it works:
17 |
18 | ```cs
19 | var httpClient = new HttpClient(new NativeMessageHandler());
20 | ```
21 |
22 | ## How can I use this in a PCL?
23 |
24 | Just reference the Portable version of ModernHttpClient in your Portable
25 | Library, and it will use the correct version on all platforms.
26 |
27 | ## Building
28 |
29 | ```sh
30 | make
31 | ```
32 |
33 | ## Why doesn't this build in Xamarin Studio? What gives?
34 |
35 | ```sh
36 | ## Run this first
37 | make
38 | ```
39 |
--------------------------------------------------------------------------------
/src/ModernHttpClient/CaptiveNetworkException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 |
4 | namespace ModernHttpClient
5 | {
6 | ///
7 | /// Thrown when the request goes to a captive network. This happens
8 | /// usually with wifi networks where an authentication html form is shown
9 | /// instead of the real content.
10 | ///
11 | public class CaptiveNetworkException : WebException
12 | {
13 | const string DefaultCaptiveNetworkErrorMessage = "Hostnames don't match, you are probably on a captive network";
14 |
15 | ///
16 | /// Gets the source URI.
17 | ///
18 | /// The source URI.
19 | public Uri SourceUri { get; private set; }
20 |
21 | ///
22 | /// Gets the destination URI.
23 | ///
24 | /// The destination URI.
25 | public Uri DestinationUri { get; private set; }
26 |
27 | public CaptiveNetworkException(Uri sourceUri, Uri destinationUri) : base(DefaultCaptiveNetworkErrorMessage)
28 | {
29 | SourceUri = sourceUri;
30 | DestinationUri = destinationUri;
31 | }
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/src/ModernHttpClient/iOS/NativeCookieHandler.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.Net;
4 |
5 | #if UNIFIED
6 | using Foundation;
7 | #else
8 | using MonoTouch.Foundation;
9 | #endif
10 |
11 | namespace ModernHttpClient
12 | {
13 | public class NativeCookieHandler
14 | {
15 | public void SetCookies(IEnumerable cookies)
16 | {
17 | foreach (var v in cookies.Select(ToNativeCookie)) {
18 | NSHttpCookieStorage.SharedStorage.SetCookie(v);
19 | }
20 | }
21 |
22 | public List Cookies {
23 | get {
24 | return NSHttpCookieStorage.SharedStorage.Cookies
25 | .Select(ToNetCookie)
26 | .ToList();
27 | }
28 | }
29 |
30 | static NSHttpCookie ToNativeCookie(Cookie cookie)
31 | {
32 | return new NSHttpCookie(cookie);
33 | }
34 |
35 | static Cookie ToNetCookie(NSHttpCookie cookie)
36 | {
37 | var nc = new Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain);
38 | nc.Secure = cookie.IsSecure;
39 |
40 | return nc;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/DotNet.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file contains the sample code to use System.Net.WebRequest
3 | // on Android to communicate with HTTP servers
4 | //
5 | // Author:
6 | // Miguel de Icaza
7 | //
8 |
9 | using System;
10 | using System.Net;
11 | using System.Diagnostics;
12 |
13 | namespace HttpClient.Android
14 | {
15 | public class DotNet {
16 | MainActivity ad;
17 |
18 | public DotNet (MainActivity ad)
19 | {
20 | this.ad = ad;
21 | }
22 |
23 | //
24 | // Asynchronous HTTP request
25 | //
26 | public void HttpSample ()
27 | {
28 | this.ad.Busy ();
29 | var request = WebRequest.Create (MainActivity.WisdomUrl);
30 | request.BeginGetResponse (FeedDownloaded, request);
31 | }
32 |
33 | //
34 | // Invoked when we get the stream back from the twitter feed
35 | // We parse the RSS feed and push the data into a
36 | // table.
37 | //
38 | void FeedDownloaded (IAsyncResult result)
39 | {
40 | var request = result.AsyncState as HttpWebRequest;
41 |
42 | try {
43 | var response = request.EndGetResponse (result);
44 | this.ad.RenderStream (response.GetResponseStream ());
45 | } catch (Exception e) {
46 | Debug.WriteLine (e);
47 | } finally {
48 | this.ad.Done ();
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Playground.iOS/Playground_iOSViewController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Xamarin Studio to store outlets and
4 | // actions made in the UI designer. If it is removed, they will be lost.
5 | // Manual changes to this file may not be handled correctly.
6 | //
7 | using Foundation;
8 | using System.CodeDom.Compiler;
9 |
10 | namespace Playground.iOS
11 | {
12 | [Register ("Playground_iOSViewController")]
13 | partial class Playground_iOSViewController
14 | {
15 | [Outlet]
16 | UIKit.UIProgressView progress { get; set; }
17 |
18 | [Outlet]
19 | UIKit.UILabel md5sum { get; set; }
20 |
21 | [Outlet]
22 | UIKit.UITextView result { get; set; }
23 |
24 | [Action ("cancelIt:")]
25 | partial void cancelIt (Foundation.NSObject sender);
26 |
27 | [Action ("doIt:")]
28 | partial void doIt (Foundation.NSObject sender);
29 |
30 | void ReleaseDesignerOutlets ()
31 | {
32 | if (result != null) {
33 | result.Dispose ();
34 | result = null;
35 | }
36 |
37 | if (md5sum != null) {
38 | md5sum.Dispose ();
39 | md5sum = null;
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/DotNet.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file contains the sample code to use System.Net.WebRequest
3 | // on the iPhone to communicate with HTTP and HTTPS servers
4 | //
5 | // Author:
6 | // Miguel de Icaza
7 | //
8 |
9 | using System;
10 | using System.Net;
11 | using Foundation;
12 | using System.Security.Cryptography.X509Certificates;
13 | using System.Diagnostics;
14 |
15 | namespace HttpClient
16 | {
17 | public class DotNet {
18 | AppDelegate ad;
19 |
20 | public DotNet (AppDelegate ad)
21 | {
22 | this.ad = ad;
23 | }
24 |
25 | //
26 | // Asynchronous HTTP request
27 | //
28 | public void HttpSample ()
29 | {
30 | Application.Busy ();
31 | var request = WebRequest.Create (Application.WisdomUrl);
32 | request.BeginGetResponse (FeedDownloaded, request);
33 | }
34 |
35 | //
36 | // Invoked when we get the stream back from the twitter feed
37 | // We parse the RSS feed and push the data into a
38 | // table.
39 | //
40 | void FeedDownloaded (IAsyncResult result)
41 | {
42 | Application.Done ();
43 | var request = result.AsyncState as HttpWebRequest;
44 |
45 | try {
46 | var response = request.EndGetResponse (result);
47 | ad.RenderStream (response.GetResponseStream ());
48 | } catch (Exception e) {
49 | Debug.WriteLine (e);
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/ModernHttpClient/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ModernHttpClient")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ModernHttpClient")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // Version information for an assembly consists of the following four values:
23 | //
24 | // Major Version
25 | // Minor Version
26 | // Build Number
27 | // Revision
28 | //
29 | // You can specify all the values or you can default the Build and Revision Numbers
30 | // by using the '*' as shown below:
31 | // [assembly: AssemblyVersion("1.0.*")]
32 | [assembly: AssemblyVersion("2.4.2")]
33 | [assembly: AssemblyFileVersion("2.4.2")]
34 |
--------------------------------------------------------------------------------
/src/Playground.iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Foundation;
5 | using UIKit;
6 |
7 | namespace Playground.iOS
8 | {
9 | // The UIApplicationDelegate for the application. This class is responsible for launching the
10 | // User Interface of the application, as well as listening (and optionally responding) to
11 | // application events from iOS.
12 | [Register ("AppDelegate")]
13 | public partial class AppDelegate : UIApplicationDelegate
14 | {
15 | // class-level declarations
16 | UIWindow window;
17 | Playground_iOSViewController viewController;
18 | //
19 | // This method is invoked when the application has loaded and is ready to run. In this
20 | // method you should instantiate the window, load the UI into it and then make the window
21 | // visible.
22 | //
23 | // You have 17 seconds to return from this method, or iOS will terminate your application.
24 | //
25 | public override bool FinishedLaunching (UIApplication app, NSDictionary options)
26 | {
27 | window = new UIWindow (UIScreen.MainScreen.Bounds);
28 |
29 | viewController = new Playground_iOSViewController ();
30 | window.RootViewController = viewController;
31 | window.MakeKeyAndVisible ();
32 |
33 | return true;
34 | }
35 | }
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/HttpClient.iOS.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient", "HttpClient.csproj", "{A7833601-70B7-4E22-8CEC-0B822863286D}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|iPhoneSimulator = Debug|iPhoneSimulator
9 | Release|iPhoneSimulator = Release|iPhoneSimulator
10 | Debug|iPhone = Debug|iPhone
11 | Release|iPhone = Release|iPhone
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {A7833601-70B7-4E22-8CEC-0B822863286D}.Debug|iPhone.ActiveCfg = Debug|iPhone
15 | {A7833601-70B7-4E22-8CEC-0B822863286D}.Debug|iPhone.Build.0 = Debug|iPhone
16 | {A7833601-70B7-4E22-8CEC-0B822863286D}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
17 | {A7833601-70B7-4E22-8CEC-0B822863286D}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
18 | {A7833601-70B7-4E22-8CEC-0B822863286D}.Release|iPhone.ActiveCfg = Release|iPhone
19 | {A7833601-70B7-4E22-8CEC-0B822863286D}.Release|iPhone.Build.0 = Release|iPhone
20 | {A7833601-70B7-4E22-8CEC-0B822863286D}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
21 | {A7833601-70B7-4E22-8CEC-0B822863286D}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
22 | EndGlobalSection
23 | GlobalSection(MonoDevelopProperties) = preSolution
24 | StartupItem = HttpClient.csproj
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/src/ModernHttpClient/Resources/Resource.designer.cs:
--------------------------------------------------------------------------------
1 | #pragma warning disable 1591
2 | // ------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Mono Runtime Version: 4.0.30319.17020
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | // ------------------------------------------------------------------------------
11 |
12 | [assembly: Android.Runtime.ResourceDesignerAttribute("ModernHttpClient.Resource", IsApplication=false)]
13 |
14 | namespace ModernHttpClient
15 | {
16 |
17 |
18 | [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
19 | public partial class Resource
20 | {
21 |
22 | static Resource()
23 | {
24 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
25 | }
26 |
27 | public partial class Attribute
28 | {
29 |
30 | static Attribute()
31 | {
32 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
33 | }
34 |
35 | private Attribute()
36 | {
37 | }
38 | }
39 |
40 | public partial class String
41 | {
42 |
43 | // aapt resource value: 0x7f020000
44 | public static int library_name = 2130837504;
45 |
46 | static String()
47 | {
48 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
49 | }
50 |
51 | private String()
52 | {
53 | }
54 | }
55 | }
56 | }
57 | #pragma warning restore 1591
58 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | MDTOOL ?= /Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool
2 |
3 | .PHONY: all clean
4 |
5 | all: ModernHttpClient.iOS.dll ModernHttpClient.iOS64.dll ModernHttpClient.Android.dll ModernHttpClient.Portable.dll
6 |
7 | package: ModernHttpClient.iOS.dll ModernHttpClient.iOS64.dll ModernHttpClient.Android.dll ModernHttpClient.Portable.dll
8 | mono vendor/nuget/NuGet.exe pack ./ModernHttpClient.nuspec
9 | mv modernhttpclient*.nupkg ./build/
10 |
11 | ModernHttpClient.Android.dll:
12 | $(MDTOOL) build -c:Release ./src/ModernHttpClient/ModernHttpClient.Android.csproj
13 | mkdir -p ./build/MonoAndroid
14 | mv ./src/ModernHttpClient/bin/Release/MonoAndroid/Modern* ./build/MonoAndroid
15 |
16 | ModernHttpClient.iOS.dll:
17 | $(MDTOOL) build -c:Release ./src/ModernHttpClient/ModernHttpClient.iOS.csproj
18 | mkdir -p ./build/MonoTouch
19 | mv ./src/ModernHttpClient/bin/Release/MonoTouch/Modern* ./build/MonoTouch
20 |
21 | ModernHttpClient.iOS64.dll:
22 | $(MDTOOL) build -c:Release ./src/ModernHttpClient/ModernHttpClient.iOS64.csproj
23 | mkdir -p ./build/Xamarin.iOS10
24 | mv ./src/ModernHttpClient/bin/Release/Xamarin.iOS10/Modern* ./build/Xamarin.iOS10
25 |
26 | ModernHttpClient.Portable.dll:
27 | $(MDTOOL) build -c:Release ./src/ModernHttpClient/ModernHttpClient.Portable.csproj
28 | mkdir -p ./build/Portable-Net45+WinRT45+WP8+WPA81
29 | mv ./src/ModernHttpClient/bin/Release/Portable-Net45+WinRT45+WP8+WPA81/Modern* ./build/Portable-Net45+WinRT45+WP8+WPA81
30 |
31 | clean:
32 | $(MDTOOL) build -t:Clean ModernHttpClient.sln
33 | rm *.dll
34 | rm -rf build
35 |
--------------------------------------------------------------------------------
/src/ModernHttpClient/Android/NativeCookieHandler.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.Net;
4 | using Java.Net;
5 |
6 | namespace ModernHttpClient
7 | {
8 | public class NativeCookieHandler
9 | {
10 | readonly CookieManager cookieManager = new CookieManager();
11 |
12 | public NativeCookieHandler()
13 | {
14 | CookieHandler.Default = cookieManager; //set cookie manager if using NativeCookieHandler
15 | }
16 |
17 | public void SetCookies(IEnumerable cookies)
18 | {
19 | foreach (var nc in cookies.Select(ToNativeCookie)) {
20 | cookieManager.CookieStore.Add(new URI(nc.Domain), nc);
21 | }
22 | }
23 |
24 | public List Cookies {
25 | get {
26 | return cookieManager.CookieStore.Cookies
27 | .Select(ToNetCookie)
28 | .ToList();
29 | }
30 | }
31 |
32 | static HttpCookie ToNativeCookie(Cookie cookie)
33 | {
34 | var nc = new HttpCookie(cookie.Name, cookie.Value);
35 | nc.Domain = cookie.Domain;
36 | nc.Path = cookie.Path;
37 | nc.Secure = cookie.Secure;
38 |
39 | return nc;
40 | }
41 |
42 | static Cookie ToNetCookie(HttpCookie cookie)
43 | {
44 | var nc = new Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain);
45 | nc.Secure = cookie.Secure;
46 |
47 | return nc;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/samples/HttpClient.iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSMainNibFile
6 | MainWindow
7 | CFBundleIconFiles
8 |
9 | Resources/icon-57.png
10 | Resources/icon-114.png
11 | Resources/icon-72.png
12 | Resources/icon-144.png
13 | Resources/icon-29.png
14 | Resources/icon-58.png
15 | Resources/icon-50.png
16 | Resources/icon-100.png
17 |
18 | UIDeviceFamily
19 |
20 | 1
21 | 2
22 |
23 | MinimumOSVersion
24 | 7.0
25 | UISupportedInterfaceOrientations
26 |
27 | UIInterfaceOrientationPortrait
28 | UIInterfaceOrientationLandscapeLeft
29 | UIInterfaceOrientationLandscapeRight
30 |
31 | UISupportedInterfaceOrientations~ipad
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | CFBundleIdentifier
38 | com.modernhttpclient.httpclient
39 | CFBundleDisplayName
40 | HttpClient
41 | CFBundleShortVersionString
42 | 1.0
43 | CFBundleVersion
44 | 1.0
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/Playground.Android/Resources/layout/Main.axml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
16 |
23 |
29 |
35 |
40 |
--------------------------------------------------------------------------------
/src/ModernHttpClient/iOS/AsyncLock.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using System.Threading;
4 |
5 | #if XAMARIN_MODERN
6 | namespace System.Net.Http {
7 | sealed class AsyncLock
8 | #else
9 | namespace ModernHttpClient
10 | {
11 | // Straight-up thieved from http://www.hanselman.com/blog/ComparingTwoTechniquesInNETAsynchronousCoordinationPrimitives.aspx
12 | public sealed class AsyncLock
13 | #endif
14 | {
15 | readonly SemaphoreSlim m_semaphore;
16 | readonly Task m_releaser;
17 |
18 | public static AsyncLock CreateLocked(out IDisposable releaser)
19 | {
20 | var asyncLock = new AsyncLock(true);
21 | releaser = asyncLock.m_releaser.Result;
22 | return asyncLock;
23 | }
24 |
25 | AsyncLock(bool isLocked)
26 | {
27 | m_semaphore = new SemaphoreSlim(isLocked ? 0 : 1, 1);
28 | m_releaser = Task.FromResult((IDisposable)new Releaser(this));
29 | }
30 |
31 | public Task LockAsync()
32 | {
33 | var wait = m_semaphore.WaitAsync();
34 | return wait.IsCompleted ?
35 | m_releaser :
36 | wait.ContinueWith((_, state) => (IDisposable)state,
37 | m_releaser.Result, CancellationToken.None,
38 | TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
39 | }
40 |
41 | sealed class Releaser : IDisposable
42 | {
43 | readonly AsyncLock m_toRelease;
44 | internal Releaser(AsyncLock toRelease) { m_toRelease = toRelease; }
45 | public void Dispose() { m_toRelease.m_semaphore.Release(); }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/ModernHttpClient/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.axml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable/
12 | icon.png
13 |
14 | layout/
15 | main.axml
16 |
17 | values/
18 | strings.xml
19 |
20 | In order to get the build system to recognize Android resources, set the build action to
21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
22 | instead operate on resource IDs. When you compile an Android application that uses resources,
23 | the build system will package the resources for distribution and generate a class called "R"
24 | (this is an Android convention) that contains the tokens for each one of the resources
25 | included. For example, for the above Resources layout, this is what the R class would expose:
26 |
27 | public class R {
28 | public class drawable {
29 | public const int icon = 0x123;
30 | }
31 |
32 | public class layout {
33 | public const int main = 0x456;
34 | }
35 |
36 | public class strings {
37 | public const int first_string = 0xabc;
38 | public const int second_string = 0xbcd;
39 | }
40 | }
41 |
42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first
44 | string in the dictionary file values/strings.xml.
45 |
--------------------------------------------------------------------------------
/src/Playground.Android/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.axml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable/
12 | icon.png
13 |
14 | layout/
15 | main.axml
16 |
17 | values/
18 | strings.xml
19 |
20 | In order to get the build system to recognize Android resources, set the build action to
21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
22 | instead operate on resource IDs. When you compile an Android application that uses resources,
23 | the build system will package the resources for distribution and generate a class called "R"
24 | (this is an Android convention) that contains the tokens for each one of the resources
25 | included. For example, for the above Resources layout, this is what the R class would expose:
26 |
27 | public class R {
28 | public class drawable {
29 | public const int icon = 0x123;
30 | }
31 |
32 | public class layout {
33 | public const int main = 0x456;
34 | }
35 |
36 | public class strings {
37 | public const int first_string = 0xabc;
38 | public const int second_string = 0xbcd;
39 | }
40 | }
41 |
42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first
44 | string in the dictionary file values/strings.xml.
45 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.axml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable/
12 | icon.png
13 |
14 | layout/
15 | main.axml
16 |
17 | values/
18 | strings.xml
19 |
20 | In order to get the build system to recognize Android resources, set the build action to
21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
22 | instead operate on resource IDs. When you compile an Android application that uses resources,
23 | the build system will package the resources for distribution and generate a class called "R"
24 | (this is an Android convention) that contains the tokens for each one of the resources
25 | included. For example, for the above Resources layout, this is what the R class would expose:
26 |
27 | public class R {
28 | public class drawable {
29 | public const int icon = 0x123;
30 | }
31 |
32 | public class layout {
33 | public const int main = 0x456;
34 | }
35 |
36 | public class strings {
37 | public const int first_string = 0xabc;
38 | public const int second_string = 0xbcd;
39 | }
40 | }
41 |
42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first
44 | string in the dictionary file values/strings.xml.
45 |
--------------------------------------------------------------------------------
/component/License.md:
--------------------------------------------------------------------------------
1 | The ModernHttpClient component includes two libraries: OkHttp for Android
2 | which is under the Apache license version 2.0, and the ModernHttpClient
3 | wrapper itself which is under the MIT license.
4 |
5 | OkHttp License
6 | ==============
7 | ```
8 | Copyright 2013 Square, Inc.
9 |
10 | Licensed under the Apache License, Version 2.0 (the "License");
11 | you may not use this file except in compliance with the License.
12 | You may obtain a copy of the License at
13 |
14 | http://www.apache.org/licenses/LICENSE-2.0
15 |
16 | Unless required by applicable law or agreed to in writing, software
17 | distributed under the License is distributed on an "AS IS" BASIS,
18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | See the License for the specific language governing permissions and
20 | limitations under the License.
21 | ```
22 |
23 | ModernHttpClient License
24 | ========================
25 | ```
26 | Copyright (c) 2013 Paul Betts
27 |
28 | Permission is hereby granted, free of charge, to any person obtaining a copy of
29 | this software and associated documentation files (the "Software"), to deal in
30 | the Software without restriction, including without limitation the rights to
31 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
32 | the Software, and to permit persons to whom the Software is furnished to do so,
33 | subject to the following conditions:
34 |
35 | The above copyright notice and this permission notice shall be included in all
36 | copies or substantial portions of the Software.
37 |
38 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
40 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
41 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
42 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
43 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44 | ```
45 |
--------------------------------------------------------------------------------
/samples/HttpClient.Android/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Android.App;
4 | using Android.Content;
5 | using Android.Runtime;
6 | using Android.Views;
7 | using Android.Widget;
8 | using Android.OS;
9 | using ModernHttpClient;
10 |
11 | namespace HttpClient.Android
12 | {
13 | [Activity (Label = "Http Client Sample", MainLauncher = true)]
14 | public class MainActivity : Activity
15 | {
16 | public static readonly string WisdomUrl = "http://httpbin.org/ip";
17 | private ProgressDialog busyDlg = null;
18 |
19 | protected override void OnCreate (Bundle bundle)
20 | {
21 | base.OnCreate (bundle);
22 |
23 | // Set our view from the "main" layout resource
24 | SetContentView (Resource.Layout.Main);
25 |
26 | // Get our button from the layout resource,
27 | // and attach an event to it
28 | Button button = FindViewById