/// <summary> /// <para>Downloads the resource with the specified <see cref="Uri"/> address and returns the result in a binary form.</para> /// </summary> /// <param name="self">The URI from which to download data.</param> /// <returns>Response of web server in a binary format.</returns> /// <exception cref="ArgumentNullException">If <paramref name="self"/> is a <c>null</c> reference.</exception> /// <remarks>This method uses the RETR command to download an FTP resource. For an HTTP resource, the GET method is used.</remarks> /// <seealso cref="Bytes(Uri, IDictionary{string, object})"/> /// <seealso cref="Bytes(Uri, IDictionary{string, string})"/> /// <seealso cref="Bytes(Uri, object)"/> public static byte[] Bytes(this Uri self) { Assertion.NotNull(self); return self.Bytes((object)null); }
/// <summary> /// Amount in kilobytes /// </summary> /// <param name="amount">The amount</param> /// <returns>Amount</returns> public static int Kilobytes(this int amount) { return 1024*amount.Bytes(); }
/// <summary> /// <para>Downloads the resource with the specified <see cref="Uri"/> address and returns the result in a binary form.</para> /// </summary> /// <param name="self">The URI from which to download data.</param> /// <param name="headers">Optional set of additional headers to send alongside with request (names and values of object's public properties).</param> /// <returns>Response of web server in a binary format.</returns> /// <exception cref="ArgumentNullException">If <paramref name="self"/> is a <c>null</c> reference.</exception> /// <remarks>This method uses the RETR command to download an FTP resource. For an HTTP resource, the GET method is used.</remarks> /// <seealso cref="Bytes(Uri)"/> /// <seealso cref="Bytes(Uri, IDictionary{string, string})"/> /// <seealso cref="Bytes(Uri, IDictionary{string, object})"/> public static byte[] Bytes(this Uri self, object headers = null) { Assertion.NotNull(self); return self.Bytes(headers?.PropertiesMap()); }