jf-framework
Loading...
Searching...
No Matches
http.c File Reference
#include <http.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
Include dependency graph for http.c:

Functions

uint32_t jf_ParseHttpRequest (HttpRequest *httpRequest, const char *buffer, size_t length)
 Parses the HTTP request.
void jf_InitHttpResponse (HttpResponse *response)
 Initializes response struct.
uint32_t jf_SendHttpResponse (int32_t sockfd, const HttpResponse *response)
 Sends HTTP response.
void jf_Send (HttpResponse *httpResponse, const char *contentType, const char *body, HttpStatus status)
 Sends HTTP response.
void jf_SendString (HttpResponse *httpResponse, const char *string, HttpStatus status)
 Wrapper for jf_Send.
void jf_SendHTMLFile (HttpResponse *httpResponse, const char *path, HttpStatus status)
 Wrapper for jf_Send.
void jf_SendHTML (HttpResponse *httpResponse, const char *html, HttpStatus status)
 Wrapper for jf_Send.
void jf_SendJson (HttpResponse *httpResponse, const char *json, HttpStatus status)
 Wrapper for jf_Send.
void jf_Redirect (HttpResponse *httpResponse, const char *destination, HttpStatus status)
 Wrapper for jf_Send.
uint32_t jf_AddHeader (HttpResponse *httpResponse, const char *name, const char *value)
 Set HTTP response headers.
const char * jf_GetParameter (const HttpRequest *httpRequest, const char *key)
 Retreives parameter from http request.

Detailed Description

Author
Avis

Function Documentation

◆ jf_AddHeader()

uint32_t jf_AddHeader ( HttpResponse * httpResponse,
const char * name,
const char * value )

Set HTTP response headers.

Author
Avis
Returns
Returns 1 on success, 0 on failure
Here is the caller graph for this function:

◆ jf_GetParameter()

const char * jf_GetParameter ( const HttpRequest * httpRequest,
const char * key )

Retreives parameter from http request.

Author
Avis
Returns
Parameter value; returns value on success, NULL on failure

◆ jf_InitHttpResponse()

void jf_InitHttpResponse ( HttpResponse * response)

Initializes response struct.

Author
Avis
Here is the caller graph for this function:

◆ jf_ParseHttpRequest()

uint32_t jf_ParseHttpRequest ( HttpRequest * httpRequest,
const char * buffer,
size_t length )

Parses the HTTP request.

Authors
Avis, victor
Parameters
httpRequestHTTP request struct output param
bufferRaw buffer
lengthLength of raw buffer
Returns
0 if failure in parsing packet
Here is the caller graph for this function:

◆ jf_Redirect()

void jf_Redirect ( HttpResponse * httpResponse,
const char * destination,
HttpStatus status )

Wrapper for jf_Send.

Author
Avis
Here is the call graph for this function:

◆ jf_Send()

void jf_Send ( HttpResponse * httpResponse,
const char * contentType,
const char * body,
HttpStatus status )

Sends HTTP response.

Author
Avis
Here is the caller graph for this function:

◆ jf_SendHTML()

void jf_SendHTML ( HttpResponse * httpResponse,
const char * html,
HttpStatus status )

Wrapper for jf_Send.

Author
Avis
Here is the call graph for this function:

◆ jf_SendHTMLFile()

void jf_SendHTMLFile ( HttpResponse * httpResponse,
const char * path,
HttpStatus status )

Wrapper for jf_Send.

Author
Avis
Here is the call graph for this function:

◆ jf_SendHttpResponse()

uint32_t jf_SendHttpResponse ( int32_t sockfd,
const HttpResponse * response )

Sends HTTP response.

Author
Avis
Returns
Returns 0 on failure, 1 on success
Here is the caller graph for this function:

◆ jf_SendJson()

void jf_SendJson ( HttpResponse * httpResponse,
const char * json,
HttpStatus status )

Wrapper for jf_Send.

Author
Avis
Here is the call graph for this function:

◆ jf_SendString()

void jf_SendString ( HttpResponse * httpResponse,
const char * string,
HttpStatus status )

Wrapper for jf_Send.

Author
Avis
Here is the call graph for this function: