Skip to content

Commit 0cd980b

Browse files
committed
these commits went to the wrong files.
1 parent 39d6d68 commit 0cd980b

3 files changed

Lines changed: 21 additions & 32 deletions

File tree

src/Gotenberg.Sharp.Api.Client/Domain/Builders/Faceted/HtmlConversionBehaviorBuilder.cs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ internal HtmlConversionBehaviorBuilder(HtmlConversionBehaviors htmlConversionBeh
3434
/// <remarks>Prefer <see cref="SetBrowserWaitExpression" /> over waitDelay.</remarks>
3535
public HtmlConversionBehaviorBuilder SetBrowserWaitDelay(int seconds)
3636
{
37-
if (seconds < 0)
38-
{
39-
throw new ArgumentOutOfRangeException(nameof(seconds), "Wait delay must be zero or positive.");
40-
}
41-
4237
_htmlConversionBehaviors.WaitDelay = $"{seconds}s";
4338

4439
return this;
@@ -56,7 +51,7 @@ public HtmlConversionBehaviorBuilder SetBrowserWaitExpression(string expression)
5651
{
5752
if (expression.IsNotSet())
5853
{
59-
throw new ArgumentException("expression cannot be null or empty", nameof(expression));
54+
throw new InvalidOperationException("expression is not set");
6055
}
6156

6257
_htmlConversionBehaviors.WaitForExpression = expression;
@@ -75,14 +70,29 @@ public HtmlConversionBehaviorBuilder SetUserAgent(string userAgent)
7570
{
7671
if (userAgent.IsNotSet())
7772
{
78-
throw new ArgumentException("userAgent cannot be null or empty", nameof(userAgent));
73+
throw new InvalidOperationException("headerName is not set");
7974
}
8075

8176
_htmlConversionBehaviors.UserAgent = userAgent;
8277

8378
return this;
8479
}
8580

81+
/// <summary>
82+
/// Sets extra HTTP headers that Chromium will send when loading the HTML
83+
/// </summary>
84+
/// <param name="headerName"></param>
85+
/// <param name="headerValue"></param>
86+
/// <returns></returns>
87+
/// <exception cref="InvalidOperationException"></exception>
88+
/// <exception cref="JsonReaderException"></exception>
89+
public HtmlConversionBehaviorBuilder AddAdditionalHeaders(string headerName, string headerValue)
90+
{
91+
var header = string.Format("{0}{2}{1}", "{", "}", $"{'"'}{headerName}{'"'} : {'"'}{headerValue}{'"'}");
92+
93+
return AddAdditionalHeaders(JObject.Parse(header));
94+
}
95+
8696
/// <summary>
8797
/// Sets extra HTTP headers that Chromium will send when loading the HTML
8898
/// </summary>
@@ -93,7 +103,7 @@ public HtmlConversionBehaviorBuilder AddAdditionalHeaders(JObject extraHeaders)
93103
{
94104
if (extraHeaders == null)
95105
{
96-
throw new ArgumentNullException(nameof(extraHeaders));
106+
throw new InvalidOperationException("extraHeaders is null");
97107
}
98108

99109
_htmlConversionBehaviors.ExtraHeaders = extraHeaders;
@@ -132,11 +142,6 @@ public HtmlConversionBehaviorBuilder AddCookie(Cookie cookie)
132142
/// <returns></returns>
133143
public HtmlConversionBehaviorBuilder SetMetadata(IDictionary<string, object> dictionary)
134144
{
135-
if (dictionary == null)
136-
{
137-
throw new ArgumentNullException(nameof(dictionary));
138-
}
139-
140145
SetMetadata(JObject.FromObject(dictionary));
141146

142147
return this;
@@ -153,7 +158,7 @@ public HtmlConversionBehaviorBuilder SetMetadata(JObject metadata)
153158
{
154159
if (metadata == null)
155160
{
156-
throw new ArgumentNullException(nameof(metadata));
161+
throw new InvalidOperationException("metadata is null");
157162
}
158163

159164
_htmlConversionBehaviors.MetaData = metadata;
@@ -204,7 +209,7 @@ public HtmlConversionBehaviorBuilder SetPdfFormat(ConversionPdfFormats format)
204209
{
205210
if (format == default)
206211
{
207-
throw new ArgumentOutOfRangeException(nameof(format), "Invalid PDF format specified");
212+
throw new InvalidOperationException("Invalid PDF format specified");
208213
}
209214

210215
_htmlConversionBehaviors.PdfFormat = format;

src/Gotenberg.Sharp.Api.Client/Domain/Builders/Faceted/HtmlConversionBehaviorBuilderExtensions.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
using Newtonsoft.Json.Linq;
17-
1816
namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;
1917

2018
public static class HtmlConversionBehaviorBuilderExtensions
@@ -85,18 +83,4 @@ public static HtmlConversionBehaviorBuilder AddCookies(this HtmlConversionBehavi
8583

8684
return builder;
8785
}
88-
89-
/// <summary>
90-
/// Sets extra HTTP headers that Chromium will send when loading the HTML
91-
/// </summary>
92-
/// <param name="builder">HtmlConversionBehaviorBuilder</param>
93-
/// <param name="headerName"></param>
94-
/// <param name="headerValue"></param>
95-
/// <returns></returns>
96-
/// <exception cref="InvalidOperationException"></exception>
97-
/// <exception cref="JsonReaderException"></exception>
98-
public static HtmlConversionBehaviorBuilder AddAdditionalHeaders(this HtmlConversionBehaviorBuilder builder, string headerName, string headerValue)
99-
{
100-
return builder.AddAdditionalHeaders(new JObject { [headerName] = headerValue });
101-
}
10286
}

src/Gotenberg.Sharp.Api.Client/Infrastructure/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public static class Html
211211
public static class Shared
212212
{
213213
/// <summary>
214-
/// From the header &amp; footer tabs
214+
/// From the header & footer tabs
215215
/// </summary>
216216
public static class FileNames
217217
{

0 commit comments

Comments
 (0)