Skip to content

Commit

Permalink
Re-add extension method for application/x-www-form-urlencoded form data
Browse files Browse the repository at this point in the history
  • Loading branch information
dionrhys committed Aug 29, 2023
1 parent fb393ce commit 15df59f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/StackExchange.Utils.Http/Extensions.Send.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public static IRequestBuilder SendContent(this IRequestBuilder builder, HttpCont
}

/// <summary>
/// Adds a <see cref="NameValueCollection"/> as the body for this request.
/// Adds a <see cref="NameValueCollection"/> as the body for this request, with a content type of
/// <c>multipart/form-data</c>.
/// </summary>
/// <param name="builder">The builder we're working on.</param>
/// <param name="form">The <see cref="NameValueCollection"/> (e.g. FormCollection) to use.</param>
Expand All @@ -38,7 +39,17 @@ public static IRequestBuilder SendForm(this IRequestBuilder builder, NameValueCo
}
return SendContent(builder, content);
}


/// <summary>
/// Adds a <see cref="NameValueCollection"/> as the body for this request, with a content type of
/// <c>application/x-www-form-urlencoded</c>.
/// </summary>
/// <param name="builder">The builder we're working on.</param>
/// <param name="form">The <see cref="NameValueCollection"/> (e.g. FormCollection) to use.</param>
/// <returns>The request builder for chaining.</returns>
public static IRequestBuilder SendFormUrlEncoded(this IRequestBuilder builder, NameValueCollection form) =>
SendContent(builder, new FormUrlEncodedContent(form.AllKeys.ToDictionary(k => k, v => form[v])));

/// <summary>
/// Adds raw HTML content as the body for this request.
/// </summary>
Expand Down

0 comments on commit 15df59f

Please sign in to comment.