Gazelle
view release on metacpan or search on metacpan
lib/Plack/Handler/Gazelle.xs view on Meta::CPAN
date_line[i++] = ' ';
str_s(date_line, &i, MoY[gtm.tm_mon], 3);
date_line[i++] = ' ';
str_i(date_line, &i, gtm.tm_year + 1900, 4);
date_line[i++] = ' ';
str_i(date_line, &i, gtm.tm_hour,2);
date_line[i++] = ':';
str_i(date_line, &i, gtm.tm_min,2);
date_line[i++] = ':';
str_i(date_line, &i, gtm.tm_sec,2);
date_line[i++] = ' ';
date_line[i++] = 'G';
date_line[i++] = 'M';
date_line[i++] = 'T';
date_line[i++] = 13;
date_line[i++] = 10;
return i;
}
STATIC_INLINE
int _chunked_header(char *buf, ssize_t len) {
int dlen = 0, i;
ssize_t l = len;
while ( l > 0 ) {
dlen++;
l /= 16;
}
i = dlen;
buf[i++] = 13;
buf[i++] = 10;
buf[i+1] = 0;
while ( len > 0 ) {
buf[--dlen] = xdigit[len % 16];
len /= 16;
}
return i;
}
MODULE = Plack::Handler::Gazelle PACKAGE = Plack::Handler::Gazelle
PROTOTYPES: DISABLE
BOOT:
{
AV * psgi_version;
psgi_version = newAV();
av_extend(psgi_version, 2);
(void)av_push(psgi_version,newSViv(1));
(void)av_push(psgi_version,newSViv(1));
SvREADONLY_on((SV*)psgi_version);
HV *e;
e = newHV();
(void)hv_stores(e,"SCRIPT_NAME", newSVpvs(""));
(void)hv_stores(e,"psgi.version", newRV((SV*)psgi_version));
(void)hv_stores(e,"psgi.errors", newRV((SV*)PL_stderrgv));
(void)hv_stores(e,"psgi.url_scheme", newSVpvs("http"));
(void)hv_stores(e,"psgi.run_once", newSV(0));
(void)hv_stores(e,"psgi.multithread", newSV(0));
(void)hv_stores(e,"psgi.multiprocess", newSViv(1));
(void)hv_stores(e,"psgi.streaming", newSViv(1));
(void)hv_stores(e,"psgi.nonblocking", newSV(0));
(void)hv_stores(e,"psgix.input.buffered", newSViv(1));
(void)hv_stores(e,"psgix.harakiri", newSViv(1));
/* stolenn from Feersum */
/* placeholders that get defined for every request */
(void)hv_stores(e, "SERVER_PROTOCOL", &PL_sv_undef);
(void)hv_stores(e, "SERVER_NAME", &PL_sv_undef);
(void)hv_stores(e, "SERVER_PORT", &PL_sv_undef);
(void)hv_stores(e, "REQUEST_URI", &PL_sv_undef);
(void)hv_stores(e, "REQUEST_METHOD", &PL_sv_undef);
(void)hv_stores(e, "PATH_INFO", &PL_sv_undef);
(void)hv_stores(e, "REMOTE_ADDR", &PL_sv_placeholder);
(void)hv_stores(e, "REMOTE_PORT", &PL_sv_placeholder);
/* defaults that get changed for some requests */
(void)hv_stores(e, "psgi.input", &PL_sv_placeholder);
(void)hv_stores(e, "CONTENT_LENGTH", &PL_sv_placeholder);
(void)hv_stores(e, "QUERY_STRING", &PL_sv_placeholder);
/* anticipated headers */
(void)hv_stores(e, "CONTENT_TYPE", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_HOST", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_USER_AGENT", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_ACCEPT", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_ACCEPT_LANGUAGE", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_ACCEPT_CHARSET", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_REFERER", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_COOKIE", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_IF_MODIFIED_SINCE", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_IF_NONE_MATCH", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_IF_MODIFIED_SINCE", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_IF_NONE_MATCH", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_CACHE_CONTROL", &PL_sv_placeholder);
(void)hv_stores(e, "HTTP_X_FORWARDED_FOR", &PL_sv_placeholder);
env_template = e;
}
SV *
accept_psgi(fileno, timeout, tcp, host, port)
int fileno
double timeout
int tcp
SV * host
SV * port
PREINIT:
int fd;
struct sockaddr_in cliaddr;
unsigned int len;
char read_buf[MAX_HEADER_SIZE];
HV * env;
int flag = 1;
ssize_t rv = 0;
ssize_t buf_len;
ssize_t reqlen;
PPCODE:
{
/* if ( my ($conn, $buf, $env) = accept_buffer(fileno($server),timeout,tcp,host,port) */
( run in 1.587 second using v1.01-cache-2.11-cpan-140bd7fdf52 )