Test file upload using HTTP PUT method

In my opinion the best tool for such testing is curl. Its –upload-file option uploads a file by PUT, which is exactly what you want (and it can do much more, like modifying HTTP headers, in case you need it): curl http://myservice –upload-file file.txt

What is the syntax for adding an element to a scala.collection.mutable.Map?

The point is that the first line of your code is not what you expected. You should use: val map = scala.collection.mutable.Map[A,B]() You then have multiple equivalent alternatives to add items: scala> val map = scala.collection.mutable.Map[String,String]() map: scala.collection.mutable.Map[String,String] = Map() scala> map(“k1”) = “v1” scala> map res1: scala.collection.mutable.Map[String,String] = Map((k1,v1)) scala> map += “k2” -> … Read more

PHP cURL HTTP PUT

Just been doing that myself today… here is code I have working for me… $data = array(“a” => $a); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “PUT”); curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data)); $response = curl_exec($ch); if (!$response) { return false; } src: http://www.lornajane.net/posts/2009/putting-data-fields-with-php-curl

How to send a POST request with BODY in swift

If you are using Alamofire v4.0+ then the accepted answer would look like this: let parameters: [String: Any] = [ “IdQuiz” : 102, “IdUser” : “iosclient”, “User” : “iosclient”, “List”: [ [ “IdQuestion” : 5, “IdProposition”: 2, “Time” : 32 ], [ “IdQuestion” : 4, “IdProposition”: 3, “Time” : 9 ] ] ] Alamofire.request(“http://myserver.com”, method: … Read more

How to send PUT, DELETE HTTP request in HttpURLConnection?

To perform an HTTP PUT: URL url = new URL(“http://www.example.com/resource”); HttpURLConnection httpCon = (HttpURLConnection) url.openConnection(); httpCon.setDoOutput(true); httpCon.setRequestMethod(“PUT”); OutputStreamWriter out = new OutputStreamWriter( httpCon.getOutputStream()); out.write(“Resource content”); out.close(); httpCon.getInputStream(); To perform an HTTP DELETE: URL url = new URL(“http://www.example.com/resource”); HttpURLConnection httpCon = (HttpURLConnection) url.openConnection(); httpCon.setDoOutput(true); httpCon.setRequestProperty( “Content-Type”, “application/x-www-form-urlencoded” ); httpCon.setRequestMethod(“DELETE”); httpCon.connect();

RAW POST using cURL in PHP

I just found the solution, kind of answering to my own question in case anyone else stumbles upon it. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, “http://url/url/url” ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, “body goes here” ); curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: text/plain’)); $result = curl_exec($ch);

Is there any way to do HTTP PUT in python

I’ve used a variety of python HTTP libs in the past, and I’ve settled on requests as my favourite. Existing libs had pretty useable interfaces, but code can end up being a few lines too long for simple operations. A basic PUT in requests looks like: payload = {‘username’: ‘bob’, ’email’: ‘bob@bob.com’} >>> r = … Read more

What is the main difference between PATCH and PUT request?

HTTP verbs are probably one of the most cryptic things about the HTTP protocol. They exist, and there are many of them, but why do they exist? Rails seems to want to support many verbs and add some verbs that aren’t supported by web browsers natively. Here’s an exhaustive list of http verbs: http://annevankesteren.nl/2007/10/http-methods There … Read more

Should a RESTful ‘PUT’ operation return something….

The HTTP specification (RFC 2616) has a number of recommendations that are applicable. Here is my interpretation: HTTP status code 200 OK for a successful PUT of an update to an existing resource. No response body needed. (Per Section 9.6, 204 No Content is even more appropriate.) HTTP status code 201 Created for a successful … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)