I've resolved this issue working with the developer of the server. Turns out there was an issue with the way the server handled connections. Resolved.
On Sat, Sep 13, 2014 at 12:23 PM, Peter Bernhardt <[email protected] > wrote: > I have an issue processing responses from a server to a PUT request (same > happens with POST). Starts with the following CORS pre-flight request. > > Request: > > OPTIONS /open/Patient/1 HTTP/1.1 > Host: remoteserver.com > Connection: keep-alive > Pragma: no-cache > Cache-Control: no-cache > Access-Control-Request-Method: PUT > Origin: http://myclient > User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, > like Gecko) Chrome/37.0.2062.120 Safari/537.36 > Access-Control-Request-Headers: accept, content-type > Accept: */* > DNT: 1 > Referer: http://myclient/patient/2JT > Accept-Encoding: gzip,deflate,sdch > Accept-Language: en-US,en;q=0.8 > > Response: > > HTTP/1.1 200 OK > Connection: keep-alive > Content-Length: 0 > Date: Sat, 13 Sep 2014 16:58:28 GMT > Access-Control-Allow-Origin: * > Access-Control-Expose-Headers: Content-Location, Location > Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS > Access-Control-Allow-Headers: accept, content-type > Access-Control-Request-Method: GET, POST, PUT, DELETE > Server: Name of remote server > > Then the actual request: > > PUT /open/Patient/1 HTTP/1.1 > Host: remoteserver.com > Connection: keep-alive > Content-Length: 775 > Pragma: no-cache > Cache-Control: no-cache > Accept: application/json+fhir, application/json, text/plain, */* > Origin: http://myclient > User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, > like Gecko) Chrome/37.0.2062.120 Safari/537.36 > Content-Type: application/json+fhir > DNT: 1 > Referer: http://myclient/patient/2JT > Accept-Encoding: gzip,deflate,sdch > Accept-Language: en-US,en;q=0.8 > > The response is not processed by AngularJS, instead it reports the > following error: > > net::ERR_METHOD_NOT_SUPPORTED > > The body of the response is empty, and the status is "0". Thing is, if I > set a break point in the Chrome debugger and walk the call through to the > AngularJS implementation of the XHR call, I DO get a successful response. > Here's what I get in the response: > > HTTP/1.1 200 OK > Connection: keep-alive > Content-Encoding: gzip > Content-Type: application/json+fhir; charset=UTF-8 > Content-Length: 154 > Date: Sat, 13 Sep 2014 17:13:35 GMT > Pragma: no-cache > Access-Control-Allow-Origin: * > Access-Control-Expose-Headers: Content-Location, Location > Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS > Content-Location: http://remoteserver/open/Patient/1/_history/6 > Server: Health Intersections FHIR Server > > Here's the body of my code that sends the request using $http: > > function updateResource(resourceUrl, resource) { > var deferred = $q.defer(); > $http.put(resourceUrl, resource) > .success(function (data, status, headers, config) { > var results = {}; > results.data = data; > results.headers = headers(); > results.status = status; > results.config = config; > deferred.resolve(results); > }) > .error(function (data, status) { > var error = { "status": status, "outcome": data }; > deferred.reject(error); > }); > return deferred.promise; > } > > Obviously this is a timing issue. The response from the server is > prematurely processed by XHR. But why? > > Thanks in advance for any help or suggestions for further investigation. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "AngularJS" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/angular/-Il3dgiM0FQ/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
