mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 03:02:22 -05:00
Fix: implement If-None-Match header to avoid unwanted message overwrite
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@297 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
9f9e588729
commit
fca97a7214
@ -220,7 +220,8 @@ public class CaldavConnection extends AbstractConnection {
|
||||
// only current user for now
|
||||
&& session.getEmail().equalsIgnoreCase(paths[2])) {
|
||||
String etag = headers.get("if-match");
|
||||
int status = session.createOrUpdateEvent(paths[4], body, etag);
|
||||
String noneMatch = headers.get("if-none-match");
|
||||
int status = session.createOrUpdateEvent(paths[4], body, etag, noneMatch);
|
||||
sendHttpResponse(status, true);
|
||||
|
||||
} else if ("DELETE".equals(command) && "users".equals(paths[1]) && paths.length == 5 && "calendar".equals(paths[3])
|
||||
|
@ -1027,7 +1027,7 @@ public class ExchangeSession {
|
||||
return line.substring(0, keyIndex) + ";VALUE=DATE:" + line.substring(valueIndex + 1, valueEndIndex);
|
||||
}
|
||||
|
||||
public int createOrUpdateEvent(String path, String icsBody, String etag) throws IOException {
|
||||
public int createOrUpdateEvent(String path, String icsBody, String etag, String noneMatch) throws IOException {
|
||||
String messageUrl = URIUtil.encodePathQuery(calendarUrl + "/" + URIUtil.decode(path));
|
||||
String uid = path.substring(0, path.lastIndexOf("."));
|
||||
PutMethod putmethod = new PutMethod(messageUrl);
|
||||
@ -1036,6 +1036,9 @@ public class ExchangeSession {
|
||||
if (etag != null) {
|
||||
putmethod.setRequestHeader("If-Match", etag);
|
||||
}
|
||||
if (noneMatch != null) {
|
||||
putmethod.setRequestHeader("If-None-Match", noneMatch);
|
||||
}
|
||||
putmethod.setRequestHeader("Content-Type", "message/rfc822");
|
||||
StringBuilder body = new StringBuilder();
|
||||
body.append("Content-Transfer-Encoding: 7bit\n" +
|
||||
|
Loading…
Reference in New Issue
Block a user