http-put

What is idempotency in HTTP PUT? Can I disallow overwriting of a resource?

丶灬走出姿态 提交于 2019-12-08 12:13:38
问题 I'm writing a REST API and I wish to allow authenticated users with the proper permissions to upload files via this API. I thought I'd use a PUT endpoint to handle this. I want to include a failsafe where the request will be rejected with a 400 -family error if the resource already exists and the user did not specify via a query that the resource should be overwritten (i.e. PUT https://my.server.com/api/files/path/to/file.txt?overwrite=1 ). The HTTP/1.1 RFC documentation of PUT suggests that

Why does a PUT 403 show up as Aborted?

匆匆过客 提交于 2019-12-08 11:52:22
问题 I've made a dummy django view that accepts PUT requests: # urls.py url(r'^put/.*$', 'put', name='put'), # views.py def put(request): print request.method return HttpResponse() Now, when I try to make a PUT xhr call to the view, it returns a 403: [27/Sep/2012 22:32:43] "PUT /put/x-unconverted/e02ed7da08d411e2bfa974de2b4d1b84?partNumber=115&uploadId=35UxOsGCCG98rke3VjpazmCy.0ZFpesndJ.XPp5Bw6R2CumfIsYKP5DlBYPY3gh3I0PCwfCg4DqSRttYp75bZg-- HTTP/1.1" 403 156400 ( why it returns 403, I don't care

HTTP 403 while executing a PUT request

孤者浪人 提交于 2019-12-07 07:13:24
I am creating a django rest api, and I'm trying to send JSON data via PUT request from an Android device, using HttpUrlConnection. URL url = new URL(myurl); conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(10000 /* milliseconds */); conn.setConnectTimeout(15000 /* milliseconds */); conn.setRequestMethod("PUT"); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); conn.setRequestProperty("Accept", "application/json"); Log.v("Apiput", MainActivity.cookieManager.getCookieStore().getCookies().get(0).toString(

Java: HTTP PUT with HttpURLConnection

回眸只為那壹抹淺笑 提交于 2019-12-07 02:35:47
问题 How do you do do an HTTP PUT? The class I'm using seems to think it is doing a PUT but the endpoint is treating it as if I did a GET. Am I doing anything wrong? URL url = new URL("https://..."); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("PUT"); OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream()); writer.write(xmlString); writer.close(); System.out.println(conn.getRequestMethod()); String response =

Sending PUT/DELETE data with a XMLHttpRequest

谁说胖子不能爱 提交于 2019-12-06 18:06:28
问题 I used the example from Send POST data using XMLHttpRequest to create this JavaScript code: function PostXML(webURL, post_data) { var objHTTP = new ActiveXObject("MSXML2.XMLHTTP"); objHTTP.open("POST", webURL, false); objHTTP.setRequestHeader("Content-Type", "application/xml; charset=utf-8"); objHTTP.setRequestHeader("Accept", "application/xml; charset=utf-8"); objHTTP.setRequestHeader("Content-Length", post_data.length); objHTTP.send(post_data); while((objHTTP.readyState != 4) && (objHTTP

Uploading a file using ruby Net:HTTP API to a remote apache server failing with 409 Conflict

若如初见. 提交于 2019-12-06 05:13:11
Below is a program to upload a file from local file system to a remote Apache server. The program ends with a 409 conflict error. Is there any advice what am I doing wrong? I turned DAV on in httpd.conf and gave all necessary permissions, but I still had no luck. I can post the httpd.conf should it be needed. This is the code: BOUNDARY = "AaB03xZZZZZZ11322321111XSDW" uri = URI.parse("http://localhost/dropbox/") file = "/tmp/KEYS.txt" http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Put.new(uri.request_uri) request.body_stream=File.open(file) request["Content-Type"] = "multipart

Should I allow sending complete structures when using PUT for updates in a REST API or not?

ⅰ亾dé卋堺 提交于 2019-12-06 01:43:58
I am designing a REST API and I wonder what the recommended way to handle updates to resources would be. More specifically, I would allow updates through a PUT on the resource, but what should I allow in the body of the PUT request? Always the complete structure of the resource? Always the subpart (that changed) of the structure of the resource? A combination of both? For example, take the resource http://example.org/api/v1/dogs/packs/p1 . A GET on this resource would give the following: Request: GET http://example.org/api/v1/dogs/packs/p1 Accept: application/xml Response: <pack> <owner>David<

Java: HTTP PUT with HttpURLConnection

╄→гoц情女王★ 提交于 2019-12-05 05:29:48
How do you do do an HTTP PUT? The class I'm using seems to think it is doing a PUT but the endpoint is treating it as if I did a GET. Am I doing anything wrong? URL url = new URL("https://..."); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("PUT"); OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream()); writer.write(xmlString); writer.close(); System.out.println(conn.getRequestMethod()); String response = readInputStream(conn.getInputStream()); System.out.println(response); Which is printing: PUT <same

How is a HTTP PUT request typically issued?

孤人 提交于 2019-12-03 06:06:18
I know HTTP PUT is an idempotent request that store something at a specific URI, according to the definition (quoted from the rfc ) The PUT method requests that the enclosed entity be stored under the supplied Request-URI. But what is the definition of 'enclosed entity'? It doesn't seem possible for me to send form data (like for HTTP POST request) over. What about sending representation of the entity via JSON/XML or in other serialization formats? In short, how does one send a HTTP PUT request over to store/update info at a specific URI then? The enclosed entity is the payload data contained

ASIHTTP: Upload UIImage?

人盡茶涼 提交于 2019-12-03 04:38:40
问题 Can someone please tell me how I can use an ASIHTTPRequest object in Objective-c to upload an UIImage object? Do I need to convert it to an NSData object? (This is for an avatar upload url) E.g. UIImage *toUpload = [UIImage imageNamed:@"test.jpg"] URL: "http://www.example.com/api/users/avatar/upload?access_token=12345" RequestType: PUT 回答1: Heres an example using ASIFormRequest that will also attempt to compress the image to given maximum size //Compress the image CGFloat compression = 0.9f;