comparison Plugins/Samples/Basic/Plugin.c @ 1042:8d1845feb277

set cookies, not allowed methods, unauthorized in plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Jul 2014 15:55:40 +0200
parents 2c49b7dffcec
children be849646b2bf
comparison
equal deleted inserted replaced
1041:2c49b7dffcec 1042:8d1845feb277
41 uint32_t i; 41 uint32_t i;
42 42
43 sprintf(buffer, "Callback on URL [%s] with body [%s]\n", url, request->body); 43 sprintf(buffer, "Callback on URL [%s] with body [%s]\n", url, request->body);
44 OrthancPluginLogWarning(context, buffer); 44 OrthancPluginLogWarning(context, buffer);
45 45
46 OrthancPluginSetCookie(context, output, "hello", "world");
46 OrthancPluginAnswerBuffer(context, output, buffer, strlen(buffer), "text/plain"); 47 OrthancPluginAnswerBuffer(context, output, buffer, strlen(buffer), "text/plain");
47 48
48 OrthancPluginLogWarning(context, ""); 49 OrthancPluginLogWarning(context, "");
49 50
50 for (i = 0; i < request->groupsCount; i++) 51 for (i = 0; i < request->groupsCount; i++)
67 { 68 {
68 sprintf(buffer, " HEADERS [%s] = [%s]", request->headersKeys[i], request->headersValues[i]); 69 sprintf(buffer, " HEADERS [%s] = [%s]", request->headersKeys[i], request->headersValues[i]);
69 OrthancPluginLogWarning(context, buffer); 70 OrthancPluginLogWarning(context, buffer);
70 } 71 }
71 72
72 OrthancPluginLogWarning(context, ""); 73 OrthancPluginLogWarning(context, "");
73 74
74 return 1; 75 return 1;
75 } 76 }
76 77
77 78
81 { 82 {
82 /* Answer with a sample 16bpp image. */ 83 /* Answer with a sample 16bpp image. */
83 84
84 uint16_t buffer[256 * 256]; 85 uint16_t buffer[256 * 256];
85 uint32_t x, y, value; 86 uint32_t x, y, value;
87
88 if (request->method != OrthancPluginHttpMethod_Get)
89 {
90 OrthancPluginSendMethodNotAllowed(context, output, "GET");
91 return -1;
92 }
86 93
87 value = 0; 94 value = 0;
88 for (y = 0; y < 256; y++) 95 for (y = 0; y < 256; y++)
89 { 96 {
90 for (x = 0; x < 256; x++, value++) 97 for (x = 0; x < 256; x++, value++)