diff --git a/.talismanrc b/.talismanrc
index 3f17ff1..f810629 100644
--- a/.talismanrc
+++ b/.talismanrc
@@ -1,3 +1,5 @@
fileignoreconfig:
- filename: Contentstack.Core/ContentstackClient.cs
- checksum: 2dd2ef59ca68dcc7c26d1136d6504272ac04b1840d242a57f9fabd603555225b
+ checksum: f960fff17b452a71e39e51ae8b92759dd1e30638d379155185e3e8bd63f407a4
+- filename: Contentstack.Core/Internals/HttpRequestHandler.cs
+ checksum: 93c1659f3bc7527956f0fd12db46441297fac3a4366d273bcbb3425d2351300e
\ No newline at end of file
diff --git a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj
index 8d19bfb..26bf739 100644
--- a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj
+++ b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj
@@ -6,12 +6,12 @@
contentstack.aspnetcore
Contentstack
Contentstack
- 2.11.0
+ 2.12.0
Main release
Copyright (c) 2012-2023 Contentstack (http://app.contentstack.com). All Rights Reserved
https://github.com/contentstack/contentstack-dotnet
- v2.11.0
- 2.11.0
+ v2.12.0
+ 2.12.0
Release;Debug
diff --git a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
index e7fbfab..dcd4138 100644
--- a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
+++ b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
@@ -4,7 +4,7 @@
net7.0
false
- 2.11.0
+ 2.12.0
diff --git a/Contentstack.Core.Tests/StackConfig.cs b/Contentstack.Core.Tests/StackConfig.cs
index 4cb8eb0..0a67f1f 100644
--- a/Contentstack.Core.Tests/StackConfig.cs
+++ b/Contentstack.Core.Tests/StackConfig.cs
@@ -37,7 +37,7 @@ public static ContentstackClient GetStack()
DeliveryToken = delivery_token,
Environment = environment,
Host = host,
-
+ Timeout = 4500
};
ContentstackClient contentstackClient = new ContentstackClient(new OptionsWrapper(contentstackOptions));
diff --git a/Contentstack.Core/Configuration/Config.cs b/Contentstack.Core/Configuration/Config.cs
index 50af06b..a7ef1a2 100644
--- a/Contentstack.Core/Configuration/Config.cs
+++ b/Contentstack.Core/Configuration/Config.cs
@@ -16,6 +16,7 @@ internal class Config
private string _Version;
private string _Environment;
private string _Branch;
+ private int _Timeout;
#endregion
#region Public Properties
@@ -60,6 +61,12 @@ public string Branch
set { this._Branch = value; }
}
+ public int Timeout
+ {
+ get { return this._Timeout; }
+ set { this._Timeout = value; }
+ }
+
public string BaseUrl
{
get
diff --git a/Contentstack.Core/Configuration/ContentstackOptions.cs b/Contentstack.Core/Configuration/ContentstackOptions.cs
index b9a9a30..079a996 100644
--- a/Contentstack.Core/Configuration/ContentstackOptions.cs
+++ b/Contentstack.Core/Configuration/ContentstackOptions.cs
@@ -58,6 +58,11 @@ public class ContentstackOptions
/// The Branch used to set Branch for the Contentstack API.
///
public string Branch { get; set; }
+
+ ///
+ /// The Timeout used to set Timeout for the Contentstack API.
+ ///
+ public int Timeout { get; set; }
}
internal class ContentstackRegionConverter : TypeConverter
diff --git a/Contentstack.Core/Contentstack.Core.csproj b/Contentstack.Core/Contentstack.Core.csproj
index 2dc5722..b521876 100644
--- a/Contentstack.Core/Contentstack.Core.csproj
+++ b/Contentstack.Core/Contentstack.Core.csproj
@@ -5,15 +5,15 @@
contentstack.csharp
Contentstack
.NET SDK for the Contentstack Content Delivery API.
- 2.11.0
+ 2.12.0
Contentstack
Reference in entry Live preview support added
Copyright © 2012-2023 Contentstack. All Rights Reserved
true
- v2.11.0
+ v2.12.0
https://github.com/contentstack/contentstack-dotnet
LICENSE.txt
- 2.11.0
+ 2.12.0
diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs
index 9c533dd..bbd5235 100644
--- a/Contentstack.Core/ContentstackClient.cs
+++ b/Contentstack.Core/ContentstackClient.cs
@@ -99,6 +99,10 @@ public ContentstackClient(IOptions options)
}
cnfig.Region = _options.Region;
cnfig.Branch = _options.Branch;
+ if (_options.Timeout != null)
+ {
+ cnfig.Timeout = _options.Timeout;
+ }
this.SetConfig(cnfig);
if (_options.LivePreview != null)
{
@@ -146,7 +150,7 @@ public ContentstackClient(ContentstackOptions options) :
/// ContentType contentType = stack.ContentType("contentType_name");
///
///
- public ContentstackClient(string apiKey, string deliveryToken, string environment, string host = null, ContentstackRegion region = ContentstackRegion.US, string version = null) :
+ public ContentstackClient(string apiKey, string deliveryToken, string environment, string host = null, ContentstackRegion region = ContentstackRegion.US, string version = null, int timeout = 100000) :
this(new OptionsWrapper(new ContentstackOptions()
{
ApiKey = apiKey,
@@ -154,7 +158,8 @@ public ContentstackClient(string apiKey, string deliveryToken, string environmen
Environment = environment,
Host = host,
Region = region,
- Version = version
+ Version = version,
+ Timeout = timeout
}
))
{
@@ -306,7 +311,7 @@ public async Task GetContentTypes(Dictionary param = null
try
{
HttpRequestHandler RequestHandler = new HttpRequestHandler(this);
- var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.Config.Branch);
+ var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.Config.Branch, timeout: this.Config.Timeout);
JObject data = JsonConvert.DeserializeObject(outputResult.Replace("\r\n", ""), this.SerializerSettings);
IList contentTypes = (IList)data["content_types"];
return contentTypes;
@@ -341,7 +346,7 @@ private async Task GetLivePreviewData()
try
{
HttpRequestHandler RequestHandler = new HttpRequestHandler(this);
- var outputResult = await RequestHandler.ProcessRequest(String.Format("{0}/content_types/{1}/entries/{2}", this.Config.getLivePreviewUrl(this.LivePreviewConfig), this.LivePreviewConfig.ContentTypeUID, this.LivePreviewConfig.EntryUID), headerAll, mainJson, Branch: this.Config.Branch, isLivePreview: true);
+ var outputResult = await RequestHandler.ProcessRequest(String.Format("{0}/content_types/{1}/entries/{2}", this.Config.getLivePreviewUrl(this.LivePreviewConfig), this.LivePreviewConfig.ContentTypeUID, this.LivePreviewConfig.EntryUID), headerAll, mainJson, Branch: this.Config.Branch, isLivePreview: true, timeout: this.Config.Timeout);
JObject data = JsonConvert.DeserializeObject(outputResult.Replace("\r\n", ""), this.SerializerSettings);
return (JObject)data["entry"];
}
@@ -739,7 +744,7 @@ private async Task GetResultAsync(string Init = "false", SyncType Syn
try
{
HttpRequestHandler requestHandler = new HttpRequestHandler(this);
- string js = await requestHandler.ProcessRequest(_SyncUrl, _LocalHeaders, mainJson, Branch: this.Config.Branch);
+ string js = await requestHandler.ProcessRequest(_SyncUrl, _LocalHeaders, mainJson, Branch: this.Config.Branch, timeout: this.Config.Timeout);
SyncStack stackSyncOutput = JsonConvert.DeserializeObject(js);
return stackSyncOutput;
}
diff --git a/Contentstack.Core/Internals/HttpRequestHandler.cs b/Contentstack.Core/Internals/HttpRequestHandler.cs
index 6ecd2c5..2817fec 100644
--- a/Contentstack.Core/Internals/HttpRequestHandler.cs
+++ b/Contentstack.Core/Internals/HttpRequestHandler.cs
@@ -1,6 +1,6 @@
using Contentstack.Core.Configuration;
using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
+using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
@@ -13,15 +13,15 @@ namespace Contentstack.Core.Internals
{
internal class HttpRequestHandler
{
- ContentstackClient client
- {
- get; set;
+ ContentstackClient client
+ {
+ get; set;
}
- internal HttpRequestHandler(ContentstackClient contentstackClient)
- {
- client = contentstackClient;
+ internal HttpRequestHandler(ContentstackClient contentstackClient)
+ {
+ client = contentstackClient;
}
- public async Task ProcessRequest(string Url, Dictionary Headers, Dictionary BodyJson, string FileName = null, string Branch = null, bool isLivePreview = false) {
+ public async Task ProcessRequest(string Url, Dictionary Headers, Dictionary BodyJson, string FileName = null, string Branch = null, bool isLivePreview = false, int timeout = 30000) {
String queryParam = String.Join("&", BodyJson.Select(kvp => {
var value = "";
@@ -48,7 +48,8 @@ public async Task ProcessRequest(string Url, Dictionary
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
request.ContentType = "application/json";
- request.Headers["x-user-agent"]="contentstack-dotnet/2.11.0";
+ request.Headers["x-user-agent"]="contentstack-delivery-dotnet/2.12.0";
+ request.Timeout = timeout;
if (Branch != null)
{
request.Headers["branch"] = Branch;
@@ -61,11 +62,11 @@ public async Task ProcessRequest(string Url, Dictionary
}
}
- }
-
- foreach (var plugin in client.Plugins)
- {
- request = await plugin.OnRequest(client, request);
+ }
+
+ foreach (var plugin in client.Plugins)
+ {
+ request = await plugin.OnRequest(client, request);
};
var serializedresult = JsonConvert.SerializeObject(BodyJson);
@@ -79,16 +80,16 @@ public async Task ProcessRequest(string Url, Dictionary
reader = new StreamReader(response.GetResponseStream());
string responseString = await reader.ReadToEndAsync();
- foreach (var plugin in client.Plugins)
- {
- responseString = await plugin.OnResponse(client, request, response, responseString);
+ foreach (var plugin in client.Plugins)
+ {
+ responseString = await plugin.OnResponse(client, request, response, responseString);
}
- if (isLivePreview == false && this.client.LivePreviewConfig.Enable == true)
- {
- JObject data = JsonConvert.DeserializeObject(responseString.Replace("\r\n", ""), this.client.SerializerSettings);
- updateLivePreviewContent(data);
- responseString = JsonConvert.SerializeObject(data);
+ if (isLivePreview == false && this.client.LivePreviewConfig.Enable == true)
+ {
+ JObject data = JsonConvert.DeserializeObject(responseString.Replace("\r\n", ""), this.client.SerializerSettings);
+ updateLivePreviewContent(data);
+ responseString = JsonConvert.SerializeObject(data);
}
return responseString;
} else {
@@ -108,44 +109,44 @@ public async Task ProcessRequest(string Url, Dictionary
}
- internal void updateLivePreviewContent(JObject response)
- {
- if (response.ContainsKey("uid") && response["uid"].ToString() == this.client.LivePreviewConfig.EntryUID)
- {
- response.Merge(this.client.LivePreviewConfig.PreviewResponse, new JsonMergeSettings()
- {
- MergeArrayHandling = MergeArrayHandling.Replace
- });
- }
- else
- {
- foreach (var content in response)
- {
- if (content.Value.Type == JTokenType.Array)
- {
- updateArray((JArray)response[content.Key]);
- }
- else if (content.Value.Type == JTokenType.Object)
- {
- updateLivePreviewContent((JObject)response[content.Key]);
- }
- }
- }
+ internal void updateLivePreviewContent(JObject response)
+ {
+ if (response.ContainsKey("uid") && response["uid"].ToString() == this.client.LivePreviewConfig.EntryUID)
+ {
+ response.Merge(this.client.LivePreviewConfig.PreviewResponse, new JsonMergeSettings()
+ {
+ MergeArrayHandling = MergeArrayHandling.Replace
+ });
+ }
+ else
+ {
+ foreach (var content in response)
+ {
+ if (content.Value.Type == JTokenType.Array)
+ {
+ updateArray((JArray)response[content.Key]);
+ }
+ else if (content.Value.Type == JTokenType.Object)
+ {
+ updateLivePreviewContent((JObject)response[content.Key]);
+ }
+ }
+ }
}
- internal void updateArray(JArray array)
- {
- for (var i = 0; i < array.Count(); i++)
- {
- if (array[i].Type == JTokenType.Array)
- {
- updateArray((JArray)array[i]);
- }
- else if (array[i].Type == JTokenType.Object)
- {
- updateLivePreviewContent((JObject)array[i]);
- }
- }
+ internal void updateArray(JArray array)
+ {
+ for (var i = 0; i < array.Count(); i++)
+ {
+ if (array[i].Type == JTokenType.Array)
+ {
+ updateArray((JArray)array[i]);
+ }
+ else if (array[i].Type == JTokenType.Object)
+ {
+ updateLivePreviewContent((JObject)array[i]);
+ }
+ }
}
}
}
diff --git a/Contentstack.Core/Models/Asset.cs b/Contentstack.Core/Models/Asset.cs
index ad91aa8..9310fe6 100644
--- a/Contentstack.Core/Models/Asset.cs
+++ b/Contentstack.Core/Models/Asset.cs
@@ -347,7 +347,7 @@ public async Task Fetch()
try
{
HttpRequestHandler RequestHandler = new HttpRequestHandler(this.StackInstance);
- var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.StackInstance.Config.Branch);
+ var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.StackInstance.Config.Branch, timeout: this.StackInstance.Config.Timeout);
JObject obj = JObject.Parse(ContentstackConvert.ToString(outputResult, "{}"));
return obj.SelectToken("$.asset").ToObject(this.StackInstance.Serializer);
}
diff --git a/Contentstack.Core/Models/AssetLibrary.cs b/Contentstack.Core/Models/AssetLibrary.cs
index 9c1a072..adeb12a 100644
--- a/Contentstack.Core/Models/AssetLibrary.cs
+++ b/Contentstack.Core/Models/AssetLibrary.cs
@@ -440,7 +440,7 @@ private async Task Exec()
try
{
HttpRequestHandler RequestHandler = new HttpRequestHandler(this.Stack);
- var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.Stack.Config.Branch);
+ var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.Stack.Config.Branch, timeout: this.Stack.Config.Timeout);
return JObject.Parse(ContentstackConvert.ToString(outputResult, "{}"));
}
diff --git a/Contentstack.Core/Models/ContentType.cs b/Contentstack.Core/Models/ContentType.cs
index b564d35..db85011 100644
--- a/Contentstack.Core/Models/ContentType.cs
+++ b/Contentstack.Core/Models/ContentType.cs
@@ -169,7 +169,7 @@ public async Task Fetch(Dictionary param = null)
try
{
HttpRequestHandler RequestHandler = new HttpRequestHandler(this.StackInstance);
- var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.StackInstance.Config.Branch);
+ var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.StackInstance.Config.Branch, timeout: this.StackInstance.Config.Timeout);
JObject data = JsonConvert.DeserializeObject(outputResult.Replace("\r\n", ""), this.StackInstance.SerializerSettings);
JObject contentTypes = (Newtonsoft.Json.Linq.JObject)data["content_type"];
return contentTypes;
diff --git a/Contentstack.Core/Models/Entry.cs b/Contentstack.Core/Models/Entry.cs
index 123845d..37c3d8f 100644
--- a/Contentstack.Core/Models/Entry.cs
+++ b/Contentstack.Core/Models/Entry.cs
@@ -1325,7 +1325,7 @@ public async Task Fetch()
}
HttpRequestHandler RequestHandler = new HttpRequestHandler(this.ContentTypeInstance.StackInstance);
- var outputResult = await RequestHandler.ProcessRequest(_Url, headerAll, mainJson, Branch: this.ContentTypeInstance.StackInstance.Config.Branch, isLivePreview: isLivePreview);
+ var outputResult = await RequestHandler.ProcessRequest(_Url, headerAll, mainJson, Branch: this.ContentTypeInstance.StackInstance.Config.Branch, isLivePreview: isLivePreview, timeout: this.ContentTypeInstance.StackInstance.Config.Timeout);
JObject obj = JObject.Parse(ContentstackConvert.ToString(outputResult, "{}"));
var serializedObject = obj.SelectToken("$.entry").ToObject(this.ContentTypeInstance.StackInstance.Serializer);
if (serializedObject.GetType() == typeof(Entry))
diff --git a/Contentstack.Core/Models/Query.cs b/Contentstack.Core/Models/Query.cs
index 5166d14..cc4226f 100644
--- a/Contentstack.Core/Models/Query.cs
+++ b/Contentstack.Core/Models/Query.cs
@@ -1792,7 +1792,7 @@ private async Task Exec()
try
{
HttpRequestHandler requestHandler = new HttpRequestHandler(this.ContentTypeInstance.StackInstance);
- var outputResult = await requestHandler.ProcessRequest(_Url, headerAll, mainJson, Branch: this.ContentTypeInstance.StackInstance.Config.Branch, isLivePreview: isLivePreview);
+ var outputResult = await requestHandler.ProcessRequest(_Url, headerAll, mainJson, Branch: this.ContentTypeInstance.StackInstance.Config.Branch, isLivePreview: isLivePreview, timeout: this.ContentTypeInstance.StackInstance.Config.Timeout);
return JObject.Parse(ContentstackConvert.ToString(outputResult, "{}"));
}
catch (Exception ex)
diff --git a/Contentstack.Net.sln b/Contentstack.Net.sln
index 625ca2b..a67c364 100644
--- a/Contentstack.Net.sln
+++ b/Contentstack.Net.sln
@@ -132,6 +132,6 @@ Global
$0.XmlFormattingPolicy = $9
$9.scope = application/xml
$0.StandardHeader = $10
- version = 2.11.0
+ version = 2.12.0
EndGlobalSection
EndGlobal