解決方法是用java(發抖)。我確定有更多的幫手庫可以更簡潔地完成這個工作,但是現在是這樣。
<cfscript>
var u = createObject("java", "java.net.URL").init("https://api.cloudflare.com/client/v4/zones/#site.zoneId#/purge_cache");
var req = u.openConnection();
req.setRequestMethod("DELETE");
req.setDoOutput(true);
req.setRequestProperty("Content-Type", "application/json");
req.setRequestProperty("X-Auth-Email", "xxxxx");
req.setRequestProperty("X-Auth-Key", "xxxx");
var os = req.getOutputStream();
os.write(javaCast("string",'{"files":#serializeJSON(urls)#}').getBytes("UTF-8"));
os.close();
ret = req.getResponseMessage();
var i = req.getInputStream();
var br = createObject("java", "java.io.BufferedReader").init(createObject("java", "java.io.InputStreamReader").init(i));
var sb = createObject("java", "java.lang.StringBuilder").init();
var line = br.readLine();
while(!isNull(line)){
sb.append(line);
line = br.readLine();
}
req.disconnect();
</cfscript>
<cfdump var="req.getResponseCode() = #req.getResponseCode()#">
<cfdump var="#ret#">
<cfdump var="#sb.toString()#">
的主體內容是不需要的刪除請求 - http://stackoverflow.com/a/299696/1636917 –
@米格爾-F - 真的,儘管我懷疑一些API的不使用它。聽起來像OP可能正在使用這樣一個API和cfhttp可能不會返回值(這不會讓我感到吃驚)。 – Leigh
你可能是正確的@Leigh。這個問題中缺乏細節很難說清楚。 –