///<summary> /// Create a <see cref="POSTContent"/> object, that includes raw byte content. ///</summary> ///<param name="data">A byte[] array containing data to be sent to the server.</param> ///<returns>A <see cref="POSTContent"/> object encapsulating the byte array data, formatted for POST requests.</returns> public static POSTContent CreateBinaryBasedContent(byte[] data) { POSTContent post = new POSTContent(); post.ByteContent = data; return(post); }
/// <summary> /// Create a <see cref="POSTContent"/> object, that includes text content, typically used for JSON, XML, or plan text. /// </summary> /// <param name="content">String data that will be sent to the server.</param> /// <returns>A <see cref="POSTContent"/> object encapsulating the string data, formatted for POST requests.</returns> public static POSTContent CreateTextBasedContent(string content) { POSTContent post = new POSTContent(); post.ByteContent = StringToByte(content); return(post); }
///<summary> /// Create a <see cref="PUTContent"/> object, that includes text content, typically used for JSON, XML, or plan text. ///</summary> ///<param name="content">String data that will be sent to the server.</param> ///<returns>A <see cref="PUTContent"/> object encapsulating the string data, formatted for PUT requests.</returns> new public static PUTContent CreateTextBasedContent(string content) { POSTContent post = POSTContent.CreateTextBasedContent(content); PUTContent put = new PUTContent(); put.ByteContent = post.ByteContent; return(put); }
///<summary> /// Create a <see cref="PUTContent"/> object, that includes raw byte content. ///</summary> ///<param name="data">A byte[] array containing data to be sent to the server.</param> ///<returns>A <see cref="PUTContent"/> object encapsulating the byte array data, formatted for PUT requests.</returns> new public static PUTContent CreateBinaryBasedContent(byte[] data) { POSTContent post = POSTContent.CreateBinaryBasedContent(data); PUTContent put = new PUTContent(); put.ByteContent = post.ByteContent; return(put); }
///<summary> /// Create a <see cref="PUTContent"/> object, that is typically used for html forms. ///</summary> ///<param name="keyValuePairs">A <see cref="T:System.Collection.IDictionary"/> object containing key/value pairs for the http body.</param> ///<returns>A <see cref="PUTContent"/> object encapsulating the key/value pairs as a byte array, formatted for PUT requests.</returns> new public static PUTContent CreateWebFormData(IDictionary keyValuePairs) { POSTContent post = POSTContent.CreateWebFormData(keyValuePairs); PUTContent put = new PUTContent(); put.ByteContent = post.ByteContent; return(put); }
///<summary> /// Create a <see cref="POSTContent"/> object, that is typically used for html forms. ///</summary> ///<param name="keyValueParamaters">A <see cref="T:System.Collection.IDictionary"/> object containing key/value pairs for the http body.</param> ///<returns>A <see cref="POSTContent"/> object encapsulating the key/value pairs as a byte array, formatted for POST requests.</returns> public static POSTContent CreateWebFormData(IDictionary keyValueParamaters) { POSTContent c = new POSTContent(); string lcontent = ""; int counter = 0; foreach (DictionaryEntry entry in keyValueParamaters) { counter++; lcontent += entry.Key + "=" + entry.Value; if (counter != keyValueParamaters.Count) { lcontent += "&"; } } c.ByteContent = StringToByte(lcontent); return(c); }
///<summary> /// Create a <see cref="POSTContent"/> object, that is typically used for html forms. ///</summary> ///<param name="keyValueParamaters">A <see cref="T:System.Collection.IDictionary"/> object containing key/value pairs for the http body.</param> ///<returns>A <see cref="POSTContent"/> object encapsulating the key/value pairs as a byte array, formatted for POST requests.</returns> public static POSTContent CreateWebFormData(IDictionary keyValueParamaters) { POSTContent c = new POSTContent(); string lcontent = ""; int counter = 0; foreach (DictionaryEntry entry in keyValueParamaters) { counter++; lcontent += entry.Key + "=" + entry.Value; if (counter != keyValueParamaters.Count) { lcontent += "&"; } } c.byteContent = StringToByte(lcontent); return c; }
/// <summary> /// Create an Http POST request. /// </summary> /// <param name="Url">The Url of the web server to which the request will be sent.</param> /// <param name="Content">The <see cref="POSTContent"/> object to be sent to the Url.</param> /// <param name="ContentType">The MIME-Type of the message.</param> /// <returns>An <see cref="HttpRequest"/> object that can be used to make POST request.</returns> public static HttpRequest CreateHttpPostRequest(string Url, POSTContent Content, string ContentType) { return new HttpRequest(HttpRequest.RequestMethod.POST, Url, Content, ContentType, null, null); }
/// <summary> /// Create an Http POST request. /// </summary> /// <param name="url">The Url of the web server to which the request will be sent.</param> /// <param name="content">The <see cref="POSTContent"/> object to be sent to the Url.</param> /// <param name="contentType">The MIME-Type of the message.</param> /// <returns>An <see cref="HttpRequest"/> object that can be used to make POST request.</returns> public static HttpRequest CreateHttpPostRequest(string url, POSTContent content, string contentType) { return(new HttpRequest(HttpRequest.RequestMethod.POST, url, content, contentType, null, null)); }
private void send_handshake() { POSTContent pc = new POSTContent(); HttpRequest hr = HttpHelper.CreateHttpPostRequest(handshakeURI, pc, ""); hr.ResponseReceived += new HttpRequest.ResponseHandler(handshake_ResponseReceived); hr.SendRequest(); Debug.Print("handshake sent"); }
///<summary> /// Create a <see cref="POSTContent"/> object, that includes raw byte content. ///</summary> ///<param name="data">A byte[] array containing data to be sent to the server.</param> ///<returns>A <see cref="POSTContent"/> object encapsulating the byte array data, formatted for POST requests.</returns> public static POSTContent CreateBinaryBasedContent(byte[] data) { POSTContent post = new POSTContent(); post.byteContent = data; return post; }
/// <summary> /// Create a <see cref="POSTContent"/> object, that includes text content, typically used for JSON, XML, or plan text. /// </summary> /// <param name="content">String data that will be sent to the server.</param> /// <returns>A <see cref="POSTContent"/> object encapsulating the string data, formatted for POST requests.</returns> public static POSTContent CreateTextBasedContent(string content) { POSTContent post = new POSTContent(); post.byteContent = StringToByte(content); return post; }
public static HttpRequest CreatePostRequest(POSTContent content, string controller) { var postRequest = HttpHelper.CreateHttpPostRequest(Globals.ApiBaseUrl + controller, content, "application/json"); AddAuthorizationHeaders(postRequest); return postRequest; }