ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
http_example.h File Reference
#include "../src/ceptr.h"
#include "../src/receptor.h"
#include "../src/protocol.h"
#include "../src/def.h"
#include "../src/semtrex.h"
#include "spec_utils.h"
#include "../src/vmhost.h"
#include "../src/accumulator.h"
#include <unistd.h>
Include dependency graph for http_example.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

T_makeTestHTTPRequestTree ()
 [makeTestHTTPRequestTree] More...
 
void _makeTestHTTPResponseProcess (Receptor *r, T **paramsP, Process *pP)
 [makeTestHTTPRequestTree] More...
 
T_makeHTTPRequestSemtrex ()
 
TmakeDeltaAdd (T *src, T *t)
 
Symbol getTag (char *otag, Symbol tag_sym[], char *tag_str[])
 
TparseHTML (char *html)
 
void testHTTPparseHTML ()
 
void * _httptester (void *arg)
 
void testHTTPedgeReceptor ()
 
void testHTTP ()
 

Variables

char * G_stxs = "/ASCII_CHARS/<HTTP_REQUEST:<HTTP_REQUEST_METHOD:ASCII_CHAR!=' '+>,ASCII_CHAR=' ',<HTTP_REQUEST_PATH:<HTTP_REQUEST_PATH_SEGMENTS:(ASCII_CHAR='/',<HTTP_REQUEST_PATH_SEGMENT:ASCII_CHAR!={'/','?',' '}*>)+>>,(ASCII_CHAR='?',<HTTP_REQUEST_PATH_QUERY:<HTTP_REQUEST_PATH_QUERY_PARAMS:(<HTTP_REQUEST_PATH_QUERY_PARAM:<PARAM_KEY:ASCII_CHAR!={'&',' ','='}+>,ASCII_CHAR='=',<PARAM_VALUE:ASCII_CHAR!={'&',' '}*>>,ASCII_CHAR='&'?)+>+>)?,ASCII_CHAR=' ',ASCII_CHAR='H',ASCII_CHAR='T',ASCII_CHAR='T',ASCII_CHAR='P',ASCII_CHAR='/',<HTTP_REQUEST_VERSION:<VERSION_MAJOR:ASCII_CHAR='0'>,ASCII_CHAR='.',<VERSION_MINOR:ASCII_CHAR='9'>>>"
 [makeTestHTTPResponseProcess]
 

Detailed Description

Definition in file http_example.h.

Function Documentation

T* _makeHTTPRequestSemtrex ( )

generate a semtrex that will match a valid HTTP request in an ASCII_CHARS tree

= ' '

Definition at line 91 of file http_example.h.

T* _makeTestHTTPRequestTree ( )

[makeTestHTTPRequestTree]

generate a test semantic tree that represents an HTTP request

T *t = _t_clone(G_http_req_example);
// confirm that we built the request right!
T *stx = _d_build_def_semtrex(G_sem,HTTP_REQUEST,0);
// puts(t2s(stx));
// puts(t2s(t));
// stx = _t_parse(G_sem,0,"(SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_LINE)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_HEADERS) (SEMTREX_SEQUENCE (SEMTREX_ZERO_OR_MORE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:CONTENT_ENCODING))))) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:HTTP_REQUEST_BODY))))");
if (!_t_match(stx,t)) {raise_error("BAD HTTP_REQUEST semtrex");}
_t_free(stx);
// all our examples are expecting the HTTP_REQUEST_LINE
T *c = _t_detach_by_idx(t,1);
_t_free(t);
return c;
}

Definition at line 26 of file http_example.h.

void _makeTestHTTPResponseProcess ( Receptor r,
T **  paramsP,
Process pP 
)

[makeTestHTTPRequestTree]

[makeTestHTTPResponseProcess] generate a test process that would generate a response to an HTTP request

// the action simply responds back with the method that was originally sent
// this test should be made more real... but for now it responds back with a ping
// like message that contains what the first path segment was
T *resp = _t_new_root(RESPOND);
_t_news(resp,CARRIER,HTTP_RESPONSE);
int pt1[] = {2,1,TREE_PATH_TERMINATOR};
_t_new(resp,PARAM_REF,pt1,sizeof(int)*3);
Process p = _r_define_process(r,resp,"code path ping","respond with the value of the first parameter",NULL,NULL);
*pP = p;
T *params = _t_build(G_sem,0,
PARAMS,
HTTP_RESPONSE,
HTTP_RESPONSE_STATUS,STATUS_VALUE,200,STATUS_TEXT,"OK",NULL_SYMBOL,
HTTP_HEADERS,
CONTENT_TYPE,MEDIA_TYPE_IDENT,TEXT_MEDIA_TYPE,MEDIA_SUBTYPE_IDENT,CEPTR_TEXT_MEDIA_SUBTYPE,NULL_SYMBOL,NULL_SYMBOL,
HTTP_RESPONSE_BODY,
SLOT,USAGE,HTTP_REQUEST_PATH_SEGMENT,NULL_SYMBOL,
NULL_SYMBOL,NULL_SYMBOL,NULL_SYMBOL
);
/* _t_new_root(PARAMS); */
/* T *http_resp = _t_newr(params,HTTP_RESPONSE); */
/* _t_new(http_resp,HTTP_RESPONSE_CONTENT_TYPE,"CeptrSymbol/HTTP_REQUEST_PATH_SEGMENT",38); */
/* T *s = _t_newr(http_resp,SLOT); */
/* _t_news(s,USAGE,HTTP_REQUEST_PATH_SEGMENT); */
*paramsP = params;
}

Definition at line 51 of file http_example.h.