Fetch_dotNET 1.2.9
dotnet add package Fetch_dotNET --version 1.2.9
NuGet\Install-Package Fetch_dotNET -Version 1.2.9
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fetch_dotNET" Version="1.2.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Fetch_dotNET --version 1.2.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Fetch_dotNET, 1.2.9"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Fetch_dotNET as a Cake Addin #addin nuget:?package=Fetch_dotNET&version=1.2.9 // Install Fetch_dotNET as a Cake Tool #tool nuget:?package=Fetch_dotNET&version=1.2.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
class Program { static async Task Main(string[] args) { Console.WriteLine("Using Fetch");
// method: 'IsConnectedToInternet'
Console.WriteLine("> IsConnectedToInternet");
bool isConnected = HttpClient.IsConnectedToInternet();
if (!isConnected) return;
Console.WriteLine("IsConnectedToInternet: " + isConnected);
// method: 'GetLocalIP OR GetPublicIP'
Console.WriteLine("> GetLocalIP OR GetPublicIP");
string myLocalIP = HttpClient.GetLocalIP();
string myPublicIP = HttpClient.GetPublicIP();
Console.WriteLine("My local IP Address is " + myLocalIP);
Console.WriteLine("My public IP Address is " + myPublicIP);
// method: 'GetMacAddress'
Console.WriteLine("> GetMacAddress");
string myMAC = HttpClient.GetMacAddress();
Console.WriteLine("My MAC Address is " + myMAC);
// method: 'PING'
Console.WriteLine("> PING");
string addressPing = "http://192.168.1.1";
//string address = "http://localhost/api/Azienda?lic_id=5383";
var httpPingResponse = HttpClient.PingHost(addressPing);
Console.WriteLine("response:");
Console.WriteLine(httpPingResponse);
DisplayResponseStatus(httpPingResponse);
// method: 'GET'
Console.WriteLine("> GET");
string address = "http://localhost/api/Azienda?lic_id=5383";
var httpResponse = HttpClient.Fetch(address);
Console.WriteLine("response:");
Console.WriteLine(httpResponse);
DisplayResponseStatus(httpResponse);
// method: 'GET WITH TIMEOUT'
Console.WriteLine("> GET WITH TIMEOUT");
httpResponse = HttpClient.Fetch(address, 3000);
//httpResponse = HttpClient.Fetch(address, "GET", "", "", 3000);
Console.WriteLine("response:");
Console.WriteLine(httpResponse);
DisplayResponseStatus(httpResponse);
// method: 'GET'
Console.WriteLine("> GET ASYNC");
address = "http://localhost/api/Azienda?lic_id=5383";
//var httpResponseAsync = HttpClient.Fetch(address, "GET");
//var httpResponseAsync = HttpClient.Fetch(address, "GET", null, null, true);
var httpResponseAsync = await HttpClient.FetchAsync(address);
Console.WriteLine("response:");
Console.WriteLine(httpResponseAsync);
DisplayResponseStatus(httpResponseAsync);
// Set the User - Agent using the WebHeaderCollection:
WebHeaderCollection headers = new WebHeaderCollection();
// Add a user agent header in case the requested URI contains a query.
headers[HttpRequestHeader.UserAgent] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
//string jwt = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1N.iJ9-nAFFxkF2L85jj9lXf6alQV1pqiIqxOmQ";
//// Adding authorization token to header
//headers[HttpRequestHeader.Authorization] = "Bearer " + jwt;
//// Resetting content type to be sent if we wanted to POST JSON
//headers[HttpRequestHeader.ContentType] = "application/json; charset=utf-8";
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("369trWQC"+":"+"5t912es"));
headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
// method: 'GET WITH BASICAUTH'
Console.WriteLine("> GET WITH BASICAUTH");
//var httpResponse = HttpClient.Fetch(address, headers);
var httpResponseBasicAuth = HttpClient.Fetch(address, "GET", "", "", false, 3000, headers);
Console.WriteLine("response:");
Console.WriteLine(httpResponseBasicAuth);
DisplayResponseStatus(httpResponseBasicAuth);
// method: 'GET WITH TOKEN JWT'
Console.WriteLine("> GET WITH TOKEN JWT");
var httpResponseJWT = HttpClient.Fetch(address, headers);
//var httpResponseJWT = HttpClient.Fetch(address, "GET", "", "", false, 3000, headers);
Console.WriteLine("response:");
Console.WriteLine(httpResponseJWT);
DisplayResponseStatus(httpResponseJWT);
// BASICAUTH
var fetchOptions1 = "{" +
"'method': 'GET'," +
"'headers': {" +
"'Accept': 'application/json'," +
"'Content-Type': 'application/json'," +
"'Authorization': 'Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes("369trWQC"+":"+"5t912es")) + "'" +
"}," +
"'timeout': 3000" +
"}";
// TOKEN JWT
var fetchOptions2 = "{" +
"'method': 'GET'," +
"'headers': {" +
"'Accept': 'application/json'," +
"'Content-Type': 'application/json'," +
"'Authorization': 'Bearer " + jwt + "'," +
"'User-Agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/6.0;)'" +
"}," +
"'timeout': 3000" + // 3 second timeout
"}";
// method: 'GET WITH TOKEN JWT'
Console.WriteLine("> GET WITH TOKEN JWT");
var httpResponseJWT = await HttpClient.FetchAsync(address, fetchOptions2, data);
Console.WriteLine("response:");
Console.WriteLine(httpResponseJWT);
DisplayResponseStatus(httpResponseJWT);
// method: 'POST'
Console.WriteLine("> POST");
string addressPost = "http://localhost/api/Appuntamenti";
string json = "{'shop_id':8000,'read':'secondary','events':[{'app_id':0,'eventType':'draft','eventColor':'lime'}]}";
var httpResponsePost = HttpClient.Fetch(addressPost, "POST", json);
Console.WriteLine("response:");
Console.WriteLine(httpResponsePost);
DisplayResponseStatus(httpResponsePost);
// method: 'POST WITH TIMEOUT'
Console.WriteLine("> POST WITH TIMEOUT");
httpResponsePost = HttpClient.Fetch(addressPost, "POST", json, "", 3000);
Console.WriteLine("response:");
Console.WriteLine(httpResponsePost);
DisplayResponseStatus(httpResponsePost);
// method: 'POST'
Console.WriteLine("> POST ASYNC");
//var httpResponsePostAsync = HttpClient.Fetch(addressPost, "POST", json, null, true);
var httpResponsePostAsync = await HttpClient.FetchAsync(addressPost, "POST", json);
Console.WriteLine("response:");
Console.WriteLine(httpResponsePostAsync);
DisplayResponseStatus(httpResponsePostAsync);
// method: 'POST'
Console.WriteLine("> POST");
var values = new NameValueCollection();
values["product"] = "Fetch_dotNET";
values["version"] = "1.0.0";
values["log"] = "13/06/20 18:51:03 ERROR ParseFormUPDATE";
string addressLog = "http://localhost/api/addLog.php";
var httpResponsePost2 = HttpClient.Fetch(addressLog, values);
//var httpResponsePost2 = HttpClient.Fetch(addressLog, "POST", values);
//var httpResponsePost2 = HttpClient.Fetch(addressLog, "POST", values, true);
Console.WriteLine("response:");
Console.WriteLine(httpResponsePost2);
DisplayResponseStatus(httpResponsePost2);
// method: 'DOWNLOAD'
Console.WriteLine("> DOWNLOAD ASYNC");
string book = "http://localhost/books/Extjs-Release1.0.0.pdf";
string fileName = @"C:\Users\matrix\Desktop\nuget_packages-SyncData\SyncData\Extjs-Release1.0.0.pdf";
var httpResponseDownload = HttpClient.FetchDownloadFile(book, fileName);
Console.WriteLine("response:");
Console.WriteLine(httpResponseDownload);
DisplayResponseStatus(httpResponseDownload);
}
private static void DisplayResponseStatus(HttpResponse httpResponse)
{
// Write results
Console.ForegroundColor = httpResponse.StatusCode == System.Net.HttpStatusCode.OK ? ConsoleColor.Green : ConsoleColor.Red;
int statusCode = (int)httpResponse.StatusCode;
Console.WriteLine("StatusCode: " + statusCode +" - "+ httpResponse.StatusCode);
var tsEnded = TimeSpan.FromTicks(httpResponse.CompleteTime.Ticks);
var tsStarted = TimeSpan.FromTicks(httpResponse.StartTime.Ticks);
var durationTs = tsEnded.Subtract(tsStarted);
var durationstr = $"{durationTs.Hours}:{durationTs.Minutes}:{durationTs.Seconds}.{durationTs.Milliseconds}";
var s = $"Total duration :{durationstr} ";
Console.WriteLine(s);
Console.ResetColor();
Console.WriteLine(String.Empty);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
- Newtonsoft.Json (>= 12.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Fetch_dotNET:
Package | Downloads |
---|---|
PushNotification_dotNET
PushNotification is a framework for Notification .NET applications. Handle Push Notifications. Across iOS, Android and UWP from a single API. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.9 | 824 | 11/3/2022 |
1.2.8 | 462 | 6/22/2022 |
1.2.7 | 517 | 11/5/2021 |
1.2.6 | 401 | 10/27/2021 |
1.2.5 | 610 | 7/25/2021 |
1.2.4 | 393 | 6/9/2021 |
1.2.3 | 393 | 3/22/2021 |
1.2.2 | 489 | 12/13/2020 |
1.2.1 | 520 | 10/24/2020 |
1.2.0 | 520 | 10/11/2020 |
1.1.1 | 466 | 8/12/2020 |
1.1.0 | 471 | 8/6/2020 |
1.0.9 | 574 | 8/6/2020 |
1.0.8 | 442 | 8/5/2020 |
1.0.7 | 436 | 8/4/2020 |
1.0.6 | 453 | 8/4/2020 |
1.0.5 | 511 | 8/3/2020 |
1.0.4 | 554 | 7/28/2020 |
1.0.3 | 477 | 7/28/2020 |
1.0.2 | 503 | 7/19/2020 |
1.0.1 | 468 | 7/19/2020 |
1.0.0 | 451 | 7/18/2020 |
Extensions on the Fetch .NetFramework.