...
|
...
|
@@ -1198,6 +1198,7 @@ wk_clientservicereadheader(_wk *web, wk_client *client)
|
1198
|
1198
|
char *sep;
|
1199
|
1199
|
wk_uri *uri;
|
1200
|
1200
|
wk_action action;
|
|
1201
|
+ int flagusepostcallback;
|
1201
|
1202
|
if((in=wk_sbufget((wk *)web, client->inbufid))==NULL)
|
1202
|
1203
|
return(-1); /* internal error */
|
1203
|
1204
|
/* get memory for the uri data */
|
...
|
...
|
@@ -1276,15 +1277,20 @@ wk_clientservicereadheader(_wk *web, wk_client *client)
|
1276
|
1277
|
sbuf_add(hbuf,"",1);
|
1277
|
1278
|
/* mark data as used */
|
1278
|
1279
|
sbuf_getbytes(in,end-sbuf_ptr(in)+4);
|
1279
|
|
- /* call the http method */
|
|
1280
|
+ /* call the http method if GET (or not post callback) , or the post method if POST */
|
1280
|
1281
|
client->uriready=1;
|
1281
|
1282
|
client->continuationactive=0;
|
1282
|
|
- action=web->callback_http((wk *)web, client->connid, uri, web->userptr);
|
|
1283
|
+ flagusepostcallback=(strcmp(client->uri.method,"POST")==0 && web->callback_post!=NULL)?1:0;
|
|
1284
|
+ if(flagusepostcallback) {
|
|
1285
|
+ action=web->callback_post((wk *)web, client->connid, uri, web->userptr);
|
|
1286
|
+ } else {
|
|
1287
|
+ action=web->callback_http((wk *)web, client->connid, uri, web->userptr);
|
|
1288
|
+ }
|
1283
|
1289
|
if(action==wkact_continuation) {
|
1284
|
1290
|
client->uriready=1;
|
1285
|
1291
|
client->continuationactive=1;
|
1286
|
1292
|
client->status=wkc_header;
|
1287
|
|
- } else if(action==wkact_post && web->callback_post!=NULL) {
|
|
1293
|
+ } else if(flagusepostcallback) {
|
1288
|
1294
|
char *lenvar;
|
1289
|
1295
|
char *contenttype;
|
1290
|
1296
|
if(strcmp(client->uri.method,"POST")!=0 ||
|
...
|
...
|
@@ -1354,7 +1360,7 @@ wk_clientservicereadpost(_wk *web, wk_client *client)
|
1354
|
1360
|
sbuf_getbytes(in,end-start);
|
1355
|
1361
|
client->pendingpost-=(end-start);
|
1356
|
1362
|
}
|
1357
|
|
- if(*sep=='&') {
|
|
1363
|
+ if(sep!=NULL && *sep=='&') {
|
1358
|
1364
|
sbuf_getbytes(in,1);
|
1359
|
1365
|
client->pendingpost--;
|
1360
|
1366
|
client->inpostvar=-1;
|
...
|
...
|
@@ -1362,14 +1368,14 @@ wk_clientservicereadpost(_wk *web, wk_client *client)
|
1362
|
1368
|
}
|
1363
|
1369
|
if(client->pendingpost>0)
|
1364
|
1370
|
return(0); /* nothing more to do for now*/
|
1365
|
|
- /* call the post method */
|
|
1371
|
+ /* call the http method */
|
1366
|
1372
|
client->uriready=1;
|
1367
|
1373
|
client->continuationactive=0;
|
1368
|
|
- action=web->callback_post((wk *)web, client->connid, client->uri, web->userptr);
|
|
1374
|
+ action=web->callback_http((wk *)web, client->connid, &(client->uri), web->userptr);
|
1369
|
1375
|
if(action==wkact_continuation) {
|
1370
|
1376
|
client->uriready=1;
|
1371
|
1377
|
client->continuationactive=1;
|
1372
|
|
- client->status=wkc_header;
|
|
1378
|
+ client->status=wkc_post;
|
1373
|
1379
|
} else {
|
1374
|
1380
|
client->uriready=1;
|
1375
|
1381
|
client->continuationactive=0;
|
...
|
...
|
@@ -1407,15 +1413,16 @@ wk_postadd(_wk *web, wk_client *client,char *varname, char *tofile)
|
1407
|
1413
|
return(-1); /* varname too long */
|
1408
|
1414
|
}
|
1409
|
1415
|
post->name=sbuf_ptrunused(buf);
|
1410
|
|
- sbuf_addstr(buf,varname);
|
|
1416
|
+ sbuf_add(buf,varname,strlen(varname)+1);
|
1411
|
1417
|
if(tofile!=NULL) {
|
1412
|
1418
|
if((strlen(tofile)+1)>(sbuf_unused(buf))) {
|
1413
|
1419
|
wk_sbufrelease((wk *)web,post->bufid),post->bufid=-1;
|
1414
|
1420
|
return(-1); /* varname+tofile too long */
|
1415
|
1421
|
}
|
1416
|
1422
|
post->tofile=sbuf_ptrunused(buf);
|
1417
|
|
- sbuf_addstr(buf,tofile);
|
|
1423
|
+ sbuf_add(buf,tofile,strlen(tofile)+1);
|
1418
|
1424
|
}
|
|
1425
|
+ client->usedpost++;
|
1419
|
1426
|
post->value=NULL;
|
1420
|
1427
|
post->filewritten=0;
|
1421
|
1428
|
post->valueterminated=0;
|