support json cookie

This commit is contained in:
root 2016-11-01 00:20:23 +00:00
parent bd8ed530b9
commit 5ebe581ea3
4 changed files with 5 additions and 5 deletions

Binary file not shown.

View File

@ -18,7 +18,7 @@ void execute(int client,const char* method,dictionary rq)
dictionary d = dict(); dictionary d = dict();
dput(d,"test",c); dput(d,"test",c);
dput(d,"test1","This is another cookie"); dput(d,"test1","This is another cookie");
set_cookie(client,d); set_cookie(client,"text/html; charset=utf-8",d);
LOG("%s",c); LOG("%s",c);
__t(client,"<h1>Set the cookie</h1>"); __t(client,"<h1>Set the cookie</h1>");

View File

@ -237,10 +237,10 @@ int upload(const char* tmp, const char* path)
{ {
return !rename(tmp, path); return !rename(tmp, path);
} }
void set_cookie(int client,dictionary dic) void set_cookie(int client,const char* type, dictionary dic)
{ {
header_base(client); header_base(client);
__t(client,"Content-Type: text/html; charset=utf-8"); __t(client,"Content-Type: %s",type);
association assoc; association assoc;
for_each_assoc(assoc,dic){ for_each_assoc(assoc,dic){
__t(client,"Set-Cookie: %s=%s",assoc->key, (char*)assoc->value); __t(client,"Set-Cookie: %s=%s",assoc->key, (char*)assoc->value);

View File

@ -57,7 +57,7 @@ char* htdocs(const char*);
sqldb getdb(); sqldb getdb();
sqldb __getdb(char *name); sqldb __getdb(char *name);
#endif #endif
void set_cookie(int,dictionary); void set_cookie(int, const char*,dictionary);
void clear_cookie(int, dictionary); void clear_cookie(int, dictionary);
/*Default function for plugin*/ /*Default function for plugin*/
void handler(int, const char*,const char*,dictionary); void handler(int, const char*,const char*,dictionary);