ProcessViewBrowser-ServerProgramming
Functions
http helper functions

Functions

int pvSendHttpChunks (PARAM *p, const char *filename)
 
int pvSendHttpContentLength (PARAM *p, const char *filename)
 
int pvSendHttpResponseFile (PARAM *p, const char *filename, const char *content_type="text/html")
 
int pvSendHttpResponse (PARAM *p, const char *html)
 

Detailed Description

These functions you can use to act as httpd. It is possible to implement your pvserver to act as pvbrowser server and httpd at the same time. Please read the manual in PDF format.

Note: You must use the -http option to start your pvserver.

./pvs -http

This will suppress the automatic sending of pvsVersion() at pvserver startup.

The full HTTP/1.1 specification can be found here:

https://www.w3.org/Protocols/rfc2616/rfc2616.html

In future we might add more helper function based on this specification. But you can implement helper functions at your own using.

int pvtcpsend(PARAM *p, const char *buf, int len);

int pvtcpsendstring(PARAM *p, const char *buf);

int pvtcpsend_binary(PARAM *p, const char *buf, int len);

int pvtcpreceive(PARAM *p, char *buf, int maxlen);

int pvtcpreceive_binary(PARAM *p, char *buf, int maxlen);

Your own httpd helper functions could be included within the upstream project. Please take care that the helper functions are usefull for wide use cases.

Function Documentation

◆ pvSendHttpChunks()

int pvSendHttpChunks ( PARAM p,
const char *  filename 
)
send http response using chunks
Example:
  pvtcpsendstring(p,
    "HTTP/1.1 200 OK\n"
    "Date: Wed, 05 Aug 2015 14:10:30 GMT\n"
    "Server: Apache/2.2.4 (Linux/SUSE)\n"
    "X-Powered-By: PHP/5.2.11\n"
    "Keep-Alive: timeout=150, max=1000\n"
    "Connection: Keep-Alive\n"
    "Transfer-Encoding: chunked\n"
    "Content-Type: text/html\n"
    "\n");
  pvSendHttpChunks(p,"test.html");

◆ pvSendHttpContentLength()

int pvSendHttpContentLength ( PARAM p,
const char *  filename 
)
send http response using Content-Length
Example: 
  sprintf(buf,"HTTP/1.1 200 OK\n"); 
  pvtcpsendstring(p,buf); 
  sprintf(buf,"Server: pvserver-%s\n", pvserver_version); 
  pvtcpsendstring(p,buf); 
  sprintf(buf,"Keep-Alive: timeout=15, max=100\n"); 
  pvtcpsendstring(p,buf); 
  sprintf(buf,"Connection: Keep-Alive\n"); 
  pvtcpsendstring(p,buf); 
  sprintf(buf,"Content-Type: text/html\n"); 
  pvtcpsendstring(p,buf); 
  pvSendHttpContentLength(p,"test.html"); 

◆ pvSendHttpResponse()

int pvSendHttpResponse ( PARAM p,
const char *  html 
)
send http response using HTML text.

◆ pvSendHttpResponseFile()

int pvSendHttpResponseFile ( PARAM p,
const char *  filename,
const char *  content_type = "text/html" 
)
send http response file
default Content-Type = text/html