CVS update: php31/sapi
| From: | shane | Date: | Sun, 23 Aug 1998 06:03:37 +0000 |
| Subject: | CVS update: php31/sapi | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-521@lists.php.net to get a copy of this message | ||
Date: Sunday August 23, 1998 @ 2:03
Author: shane
Update of /repository/php31/sapi
In directory asf:/tmp/cvs-serv3739/sapi
Modified Files:
nsapi_sapi.c
Log Message:
NSAPI
cookies and post working now.
other minor fixes
Index: php31/sapi/nsapi_sapi.c
diff -c php31/sapi/nsapi_sapi.c:2.3 php31/sapi/nsapi_sapi.c:2.4
*** php31/sapi/nsapi_sapi.c:2.3 Sat Aug 22 19:33:12 1998
--- php31/sapi/nsapi_sapi.c Sun Aug 23 02:03:36 1998
***************
*** 120,126 ****
{1, "AUTH_USER", "auth-user"},
{1, "AUTH_GROUP", "auth-group"},
{3, "CONTENT_LENGTH", "content-length"},
! {2, "CONTENT_TYPE", "content-type"},
{1, "PATH_INFO", "path-info"},
{1, "PATH_TRANSLATED", "path"},
{4, "QUERY_STRING", "query"},
--- 120,126 ----
{1, "AUTH_USER", "auth-user"},
{1, "AUTH_GROUP", "auth-group"},
{3, "CONTENT_LENGTH", "content-length"},
! {3, "CONTENT_TYPE", "content-type"},
{1, "PATH_INFO", "path-info"},
{1, "PATH_TRANSLATED", "path"},
{4, "QUERY_STRING", "query"},
***************
*** 129,157 ****
{9, "REMOTE_HOST", ""},
{1, "REMOTE_USER", "auth-user"},
! {1, "SCRIPT_NAME", "script-name"}, // ? does it work
{8, "SERVER_NAME", ""},
{8, "SERVER_HOSTNAME", ""},
{7, "SERVER_PORT", ""},
{10, "SERVER_PORT_SECURE", ""}, //well make this match HTTPS
! {4, "SERVER_PROTOCOL", "protocol"},
{6, "SERVER_SOFTWARE", ""},
{3, "HTTP_ACCEPT", "accept"},
{3, "HTTP_ACCEPT_ENCODING", "accept-encoding"}, // ? does it work
! {3, "HTTP_ACCEPT_LANGUAGE", "accept-language"}, // ? does it work
{3, "HTTP_CONNECTION", "connection"},
{3, "HTTP_HOST", "host"},
{3, "HTTP_USER_AGENT", "user-agent"},
!
{3, "HTTP_REFERER", "referer"}, // ? does it work
{10, "HTTPS", ""},
{5, "HTTPS_KEYSIZE", "keysize"},
{5, "HTTPS_SECRETKEYSIZE", "secret-keysize"},
- {4, "URL", "uri"},
{-1, NULL, NULL}
};
--- 129,159 ----
{9, "REMOTE_HOST", ""},
{1, "REMOTE_USER", "auth-user"},
! {4, "SCRIPT_NAME", "uri"},
{8, "SERVER_NAME", ""},
{8, "SERVER_HOSTNAME", ""},
{7, "SERVER_PORT", ""},
{10, "SERVER_PORT_SECURE", ""}, //well make this match HTTPS
! {4, "SERVER_PROTOCOL", "protocol"},
{6, "SERVER_SOFTWARE", ""},
{3, "HTTP_ACCEPT", "accept"},
{3, "HTTP_ACCEPT_ENCODING", "accept-encoding"}, // ? does it work
! {3, "HTTP_ACCEPT_LANGUAGE", "accept-language"}, // ? does it work
! {3, "HTTP_AUTHORIZATION", "authorization"},
! {3, "HTTP_COOKIE", "cookie"},
{3, "HTTP_CONNECTION", "connection"},
{3, "HTTP_HOST", "host"},
{3, "HTTP_USER_AGENT", "user-agent"},
! {3, "HTTP_USER_DEFINED", "user-defined" },
! {3, "HTTP_IF_MODIFIED_SINCE", "if-modified-since" },
{3, "HTTP_REFERER", "referer"}, // ? does it work
{10, "HTTPS", ""},
{5, "HTTPS_KEYSIZE", "keysize"},
{5, "HTTPS_SECRETKEYSIZE", "secret-keysize"},
{-1, NULL, NULL}
};
***************
*** 245,324 ****
return _php3_nsapi_env_get(ns_rqst, var);
}
- /*********************************************************
- / functions to get and set cookies
- /*********************************************************/
- #include "nsapi_cookie.h"
- /* ok, we can get cookies with this, but how do we get them into
- php variables? This will most likely have to be transformed into
- some other function that php calls to parse the headers.
- */
- pblock *_php3_nsapi_get_cookie_pblock(Request * rq)
- {
- char *cookie = pblock_findval("cookie", rq->headers);
- char *name, *value;
- char *ptr;
- pblock *cookie_pblock;
- int fInValue = 0;
- int done = 0;
-
- if (!cookie)
- return NULL;
-
- cookie_pblock = pblock_create(5);
-
- ptr = cookie;
- while (*ptr && isspace(*ptr))
- ptr++;
- name = ptr;
- while (!done) {
- switch (*ptr) {
- case '=':
- if (!fInValue) {
- *ptr = '\0';
- ptr++;
- while (*ptr && isspace(*ptr))
- ptr++;
- value = ptr;
- fInValue = 1;
- }
- break;
- case '\0':
- case ';':
- if (fInValue) {
- if (*ptr) {
- *ptr = '\0';
- ptr++;
- while (*ptr && isspace(*ptr))
- ptr++;
- if (!ptr) /* don't go past edge */
- ptr--;
- } else
- done = 1;
- pblock_nvinsert(name, value, cookie_pblock);
- name = ptr;
- fInValue = 0;
- }
- break;
- }
- ptr++;
- }
-
- return cookie_pblock;
- }
-
-
- /* adds a cookie to outgoing headers. We can add this to the below
- sapi_insert_header later, this is just to illustrate */
- void _php3_nsapi_set_cookie(struct ns_request_info *ns_rqst, char *cookie)
- {
- Request *rq = (Request *) ns_rqst->rq;
-
- pblock_nvinsert("Set-cookie", cookie, rq->srvhdrs);
- }
-
/*********************************************************
/ header functions
/
--- 247,254 ----
***************
*** 329,335 ****
/*FIXME need to make nsapi correctly handle redirects and status strings */
int sapi_insert_header(SAPI_GLOBAL_INCLUDE unsigned char *header)
{
! char *tempstr = NULL;
SAPI_FUNC_VARS;
#ifdef DEBUG
DEBUG_MESSAGE("enter sapi_insert_header\n");
--- 259,265 ----
/*FIXME need to make nsapi correctly handle redirects and status strings */
int sapi_insert_header(SAPI_GLOBAL_INCLUDE unsigned char *header)
{
! char *tempstr = NULL,*r;
SAPI_FUNC_VARS;
#ifdef DEBUG
DEBUG_MESSAGE("enter sapi_insert_header\n");
***************
*** 338,346 ****
/* header is in form of "headername: info"
need to split into two strings and handle from there
*/
! if (!rq->senthdrs) { /*just verify headers not already sent */
! pblock_remove("content-type", rq->srvhdrs);
! pblock_nvinsert("content-type", "text/html", rq->srvhdrs);
}
#ifdef DEBUG
DEBUG_MESSAGE("exit sapi_insert_header\n");
--- 268,308 ----
/* header is in form of "headername: info"
need to split into two strings and handle from there
*/
!
! if (!rq->senthdrs && header) {
! /*lets check to see if this is a HTTP/1.x response */
! r = strchr(header, '/');
! if (r) {
! *r = '\0';
! if (!strcasecmp(header, "HTTP")) {
! *r = '/';
! r = strchr(header, ' ');
! // sapi_info->http_status = estrdup(r + 1);
! return SUCCESS;
! }
! *r = '/';
! }
!
! r = strchr(header, ':');
! if (r) {
! *r = '\0';
! if (!strcasecmp(header, "Location")) {
! *r = ':';
! if (strspn((r+2),"://")) {/*redirect to remote system */
! sapi_info->http_redirect = 1;
! } else { /*local redirect */
! sapi_info->http_redirect = 2;
! }
! // sapi_info->http_status = estrdup(r + 2);
! return SUCCESS;
! }else if(!strcasecmp(header, "Set-cookie")){
! pblock_nvinsert(header, r+2, rq->srvhdrs);
! }else{
! pblock_remove(header, rq->srvhdrs);
! pblock_nvinsert(header, r+2, rq->srvhdrs);
! }
! *r = ':';
! }
}
#ifdef DEBUG
DEBUG_MESSAGE("exit sapi_insert_header\n");
***************
*** 505,512 ****
int sapi_readclient(SAPI_GLOBAL_INCLUDE unsigned char *buf, int len)
{
SAPI_FUNC_VARS;
!
! return net_read(sn->csd, buf, len, 10);
}
int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len)
--- 467,480 ----
int sapi_readclient(SAPI_GLOBAL_INCLUDE unsigned char *buf, int len)
{
SAPI_FUNC_VARS;
! int i=0;
! while(i<len){
! buf[i]=netbuf_getc(sn->inbuf);
! if(buf[i]==IO_ERROR || buf[i]==IO_EOF)break;
! i++;
! }
! buf[i]='\0';
! return SUCCESS;
}
int sapi_writeclient(SAPI_GLOBAL_INCLUDE unsigned char *string, int len)
***************
*** 638,683 ****
Session *sn = (Session *) ns_rqst->sn;
Request *rq = (Request *) ns_rqst->rq;
char *temp;
! #ifdef DEBUG
! DEBUG_MESSAGE("enter sapi_init\n");
! #endif
/* for cgi we dont use request id's */
sapi_info->scid = ns_rqst;
sapi_info->path_info = pblock_findval("path-info", rq->vars);
- #ifdef DEBUG
- DEBUG_MESSAGE("done with path_info\n");
- #endif
sapi_info->path_translated = pblock_findval("path", rq->vars);
! #ifdef DEBUG
! DEBUG_MESSAGE("done with path_translated\n");
! #endif
! sapi_info->rqst_filename = strdup(sapi_info->path_translated);
! #ifdef DEBUG
! DEBUG_MESSAGE("done with rqst_filename\n");
! #endif
! sapi_info->query_string = pblock_findval("query", rq->vars);
! #ifdef DEBUG
! DEBUG_MESSAGE("done with query_string\n");
! #endif
sapi_info->request_method = pblock_findval("method", rq->reqpb);
! #ifdef DEBUG
! DEBUG_MESSAGE("done with request_method\n");
! #endif
! sapi_info->script_name = pblock_findval("path", rq->vars);
! #ifdef DEBUG
! DEBUG_MESSAGE("done with script_name\n");
! #endif
temp=pblock_findval("content-length", rq->headers);
if(temp)sapi_info->content_length = atol(temp);
! #ifdef DEBUG
! DEBUG_MESSAGE("done with content_length\n");
! #endif
! sapi_info->content_type = pblock_findval("content-type", rq->srvhdrs);
- #ifdef DEBUG
- DEBUG_MESSAGE("done with content_type\n");
- #endif
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
sapi_info->flush = sapi_flush;
--- 606,626 ----
Session *sn = (Session *) ns_rqst->sn;
Request *rq = (Request *) ns_rqst->rq;
char *temp;
!
/* for cgi we dont use request id's */
sapi_info->scid = ns_rqst;
sapi_info->path_info = pblock_findval("path-info", rq->vars);
sapi_info->path_translated = pblock_findval("path", rq->vars);
! sapi_info->rqst_filename = pblock_findval("path", rq->vars);
! sapi_info->query_string = pblock_findval("query", rq->reqpb);
sapi_info->request_method = pblock_findval("method", rq->reqpb);
! sapi_info->script_name = pblock_findval("uri", rq->reqpb);
temp=pblock_findval("content-length", rq->headers);
if(temp)sapi_info->content_length = atol(temp);
! sapi_info->content_type = pblock_findval("content-type", rq->headers);
! sapi_info->cookies = pblock_findval("cookie", rq->headers);
sapi_info->getenv = sapi_getenv;
sapi_info->writeclient = sapi_writeclient;
sapi_info->flush = sapi_flush;
***************
*** 691,697 ****
sapi_info->treat_headers = sapi_treat_headers;
sapi_info->send_header = sapi_send_header;
sapi_info->headers = NULL;
- sapi_info->cookies = NULL;
sapi_info->_php3_hash_server_env = sapi__php3_hash_server_env;
sapi_info->register_clean = sapi_reqister_cleanup;
--- 634,639 ----
***************
*** 711,719 ****
sapi_info->page_uid = 0;
sapi_info->page_inode = 0;
sapi_info->page_mtime = 0;
- #ifdef DEBUG
- DEBUG_MESSAGE("sapi_init exit\n");
- #endif
}
--- 653,658 ----
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net