calendarserver.diff 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. diff -ru web2/http_headers.py web2-CardDavMATE/http_headers.py
  2. --- web2/http_headers.py 2011-10-31 00:34:14.000000000 +0100
  3. +++ web2-CardDavMATE/http_headers.py 2011-10-31 00:31:07.000000000 +0100
  4. @@ -1531,7 +1531,14 @@
  5. 'Set-Cookie2':(tokenize, parseSetCookie2),
  6. 'Vary':(tokenize, filterTokens),
  7. 'WWW-Authenticate': (lambda h: tokenize(h, foldCase=False),
  8. - parseWWWAuthenticate,)
  9. + parseWWWAuthenticate,),
  10. +
  11. + # begin CardDavMATE section
  12. + 'Access-Control-Allow-Origin':(last,),
  13. + 'Access-Control-Allow-Methods':(last,),
  14. + 'Access-Control-Allow-Headers':(last,),
  15. + 'Access-Control-Allow-Credentials':(last,),
  16. + 'Access-Control-Expose-Headers':(last,)
  17. + # end CardDavMATE section
  18. }
  19. generator_response_headers = {
  20. @@ -1545,7 +1552,14 @@
  21. 'Set-Cookie':(generateSetCookie,),
  22. 'Set-Cookie2':(generateSetCookie2,),
  23. 'Vary':(generateList, singleHeader),
  24. - 'WWW-Authenticate':(generateWWWAuthenticate,)
  25. + 'WWW-Authenticate':(generateWWWAuthenticate,),
  26. +
  27. + # begin CardDavMATE section
  28. + 'Access-Control-Allow-Origin':(str, singleHeader),
  29. + 'Access-Control-Allow-Methods':(str, singleHeader),
  30. + 'Access-Control-Allow-Headers':(str, singleHeader),
  31. + 'Access-Control-Allow-Credentials':(str, singleHeader),
  32. + 'Access-Control-Expose-Headers':(str, singleHeader)
  33. + # end CardDavMATE section
  34. }
  35. parser_entity_headers = {
  36. diff -ru web2/server.py web2-CardDavMATE/server.py
  37. --- web2/server.py 2011-10-31 00:34:21.000000000 +0100
  38. +++ web2-CardDavMATE/server.py 2011-10-31 00:31:07.000000000 +0100
  39. @@ -58,6 +58,18 @@
  40. response.headers.setHeader('server', VERSION)
  41. if not response.headers.hasHeader('date'):
  42. response.headers.setHeader('date', time.time())
  43. +
  44. + # begin CardDavMATE section
  45. + if not response.headers.hasHeader('Access-Control-Allow-Origin'):
  46. + response.headers.setHeader('Access-Control-Allow-Origin', '*')
  47. + if not response.headers.hasHeader('Access-Control-Allow-Methods'):
  48. + response.headers.setHeader('Access-Control-Allow-Methods','GET,POST,OPTIONS,PROPFIND,PROPPATCH,REPORT,PUT,MOVE,DELETE,LOCK,UNLOCK')
  49. + if not response.headers.hasHeader('Access-Control-Allow-Headers'):
  50. + response.headers.setHeader('Access-Control-Allow-Headers','User-Agent,Authorization,Content-type,Depth,If-match,If-None-Match,Lock-Token,Timeout,Destination,Overwrite,Prefer,X-client,X-Requested-With')
  51. + if not response.headers.hasHeader('Access-Control-Allow-Credentials'):
  52. + response.headers.setHeader('Access-Control-Allow-Credentials','true')
  53. + if not response.headers.hasHeader('Access-Control-Expose-Headers'):
  54. + response.headers.setHeader('Access-Control-Expose-Headers','Etag,Preference-Applied')
  55. + # end CardDavMATE section
  56. +
  57. return response
  58. defaultHeadersFilter.handleErrors = True
  59. @@ -354,7 +366,7 @@
  60. example. This would also be the place to do any CONNECT
  61. processing."""
  62. - if self.method == "OPTIONS" and self.uri == "*":
  63. + if self.method == "OPTIONS":
  64. response = http.Response(responsecode.OK)
  65. response.headers.setHeader('allow', ('GET', 'HEAD', 'OPTIONS', 'TRACE'))
  66. return response