private static MultipartFormDataContent GetMultipartFormDataContent(this ISolidHttpRequest request) { var multipart = request.BaseRequest.Content as MultipartFormDataContent; if (multipart == null) { multipart = request.WithMultipartContent(() => new MultipartFormDataContent()).BaseRequest.Content as MultipartFormDataContent; } return(multipart); }
/// <summary> /// Adds <see cref="HttpContent" /> to the inner <seealso cref="HttpRequestMessage" />. /// <para>If there is already <see cref="HttpContent" /> on the <seealso cref="HttpRequestMessage" />, it makes the request multipart.</para> /// </summary> /// <param name="request">The <see cref="ISolidHttpRequest" /> that is being extended.</param> /// <param name="content">The <see cref="HttpContent" /> to add to the <seealso cref="HttpRequestMessage" />.await</param> /// <returns>The <see cref="ISolidHttpRequest" /> so that additional calls can be chained.</returns> public static ISolidHttpRequest WithContent(this ISolidHttpRequest request, HttpContent content) { if (request.BaseRequest.Content == null) { request.BaseRequest.Content = content; return(request); } var multipart = request.WithMultipartContent(() => new MultipartContent()).BaseRequest.Content as MultipartContent; multipart.Add(content); return(request); }
/// <summary> /// Changes the sub type and boundary of the multipart content. /// </summary> /// <param name="request">The <see cref="ISolidHttpRequest" /> that is being extended.</param> /// <param name="subtype">The subtype of the multipart content</param> /// <param name="boundary">The boundary of the multipart content</param> /// <returns>The <see cref="ISolidHttpRequest" /> so that additional calls can be chained.</returns> public static ISolidHttpRequest WithSubTypeAndBoundary(this ISolidHttpRequest request, string subtype, string boundary) { return(request.WithMultipartContent(() => new MultipartContent(subtype, boundary))); }
/// <summary> /// Changes the sub type of the multipart content. /// </summary> /// <param name="request">The <see cref="ISolidHttpRequest" /> that is being extended.</param> /// <param name="subtype">The subtype of the multipart content.</param> /// <returns>The <see cref="ISolidHttpRequest" /> so that additional calls can be chained.</returns> public static ISolidHttpRequest WithSubtype(this ISolidHttpRequest request, string subtype) { return(request.WithMultipartContent(() => new MultipartContent(subtype))); }
/// <summary> /// Changes the boundary of multipart form data content. /// </summary> /// <param name="request">The <see cref="ISolidHttpRequest" /> that is being extended.</param> /// <param name="boundary">The boundary of <see cref="MultipartFormDataContent" />.</param> /// <returns>The <see cref="ISolidHttpRequest" /> so that additional calls can be chained.</returns> public static ISolidHttpRequest WithFormBoundary(this ISolidHttpRequest request, string boundary) { return(request.WithMultipartContent(() => new MultipartFormDataContent(boundary))); }