Exemplo n.º 1
0
/* kills the data */
static void stream_send_bytearr(liChunkQueue *out, guint8 type, guint16 requestid, GByteArray *data) {
	if (data->len > G_MAXUINT16) {
		stream_send_data(out, type, requestid, (const gchar*) data->data, data->len);
		g_byte_array_free(data, TRUE);
	} else {
		guint8 padlen = stream_send_fcgi_record(out, type, requestid, data->len);
		append_padding(data, padlen);
		li_chunkqueue_append_bytearr(out, data);
	}
}
Exemplo n.º 2
0
static void fastcgi_send_begin(fastcgi_connection *fcon) {
	GByteArray *buf = g_byte_array_sized_new(16);
	guint16 w;

	stream_build_fcgi_record(buf, FCGI_BEGIN_REQUEST, fcon->requestid, 8);
	w = htons(FCGI_RESPONDER);
	g_byte_array_append(buf, (const guint8*) &w, sizeof(w));
	l_byte_array_append_c(buf, 0); /* TODO: FCGI_KEEP_CONN */
	append_padding(buf, 5);
	li_chunkqueue_append_bytearr(fcon->fcgi_out, buf);
}
Exemplo n.º 3
0
static void stream_send_data(liChunkQueue *out, guint8 type, guint16 requestid, const gchar *data, size_t datalen) {
	while (datalen > 0) {
		guint16 tosend = (datalen > G_MAXUINT16) ? G_MAXUINT16 : datalen;
		guint8 padlen = stream_send_fcgi_record(out, type, requestid, tosend);
		GByteArray *tmpa = g_byte_array_sized_new(tosend + padlen);
		g_byte_array_append(tmpa, (const guint8*) data, tosend);
		append_padding(tmpa, padlen);
		li_chunkqueue_append_bytearr(out, tmpa);
		data += tosend;
		datalen -= tosend;
	}
}
Exemplo n.º 4
0
int
append_region_len (struct regions *regions,
                   const char *description, uint64_t len,
                   uint64_t pre_aligment, uint64_t post_alignment,
                   enum region_type type, ...)
{
  struct region region;

  /* Pre-alignment. */
  if (pre_aligment != 0) {
    if (append_padding (regions, pre_aligment) == -1)
      return -1;
    assert (IS_ALIGNED (virtual_size (regions), pre_aligment));
  }

  /* Main region. */
  region.description = description;
  region.start = virtual_size (regions);
  region.len = len;
  region.end = region.start + region.len - 1;
  region.type = type;
  if (type == region_file) {
    va_list ap;
    size_t i;

    va_start (ap, type);
    i = va_arg (ap, size_t);
    va_end (ap);
    region.u.i = i;
  }
  else if (type == region_data) {
    va_list ap;
    const unsigned char *data;

    va_start (ap, type);
    data = va_arg (ap, const unsigned char *);
    va_end (ap);
    region.u.data = data;
  }