Flutter Engine
The Flutter Engine
Functions
Response Namespace Reference

Functions

int SendOK (MHD_Connection *connection)
 
int SendError (MHD_Connection *connection, const char *msg)
 
int SendData (MHD_Connection *connection, const SkData *data, const char *type, bool setContentDisposition, const char *dispositionString)
 
int SendTemplate (MHD_Connection *connection, bool redirect, const char *redirectUrl)
 

Function Documentation

◆ SendData()

int Response::SendData ( MHD_Connection *  connection,
const SkData data,
const char *  type,
bool  setContentDisposition,
const char *  dispositionString 
)

Definition at line 64 of file Response.cpp.

65 {
66 MHD_Response* response = MHD_create_response_from_buffer(data->size(),
67 const_cast<void*>(data->data()),
68 MHD_RESPMEM_MUST_COPY);
69 MHD_add_response_header(response, "Content-Type", type);
70
71 if (setContentDisposition) {
72 MHD_add_response_header(response, "Content-Disposition", dispositionString);
73 }
74
75 int ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
76 MHD_destroy_response(response);
77 return ret;
78}
GLenum type
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ SendError()

int Response::SendError ( MHD_Connection *  connection,
const char *  msg 
)

Definition at line 55 of file Response.cpp.

55 {
56 MHD_Response* response = MHD_create_response_from_buffer(strlen(msg),
57 (void*) msg,
58 MHD_RESPMEM_PERSISTENT);
59 int ret = MHD_queue_response(connection, 500, response);
60 MHD_destroy_response(response);
61 return ret;
62}

◆ SendOK()

int Response::SendOK ( MHD_Connection *  connection)

Definition at line 44 of file Response.cpp.

44 {
45 const char* data = "";
46
47 MHD_Response* response = MHD_create_response_from_buffer(strlen(data),
48 (void*)data,
49 MHD_RESPMEM_PERSISTENT);
50 int ret = MHD_queue_response(connection, 200, response);
51 MHD_destroy_response(response);
52 return ret;
53}

◆ SendTemplate()

int Response::SendTemplate ( MHD_Connection *  connection,
bool  redirect,
const char *  redirectUrl 
)

Definition at line 80 of file Response.cpp.

80 {
81 SkString debuggerTemplate = generate_template(SkString(FLAGS_source[0]));
82
83 MHD_Response* response = MHD_create_response_from_buffer(
84 debuggerTemplate.size(),
85 (void*) const_cast<char*>(debuggerTemplate.c_str()),
86 MHD_RESPMEM_MUST_COPY);
87 MHD_add_response_header (response, "Access-Control-Allow-Origin", "*");
88
89 int status = MHD_HTTP_OK;
90
91 if (redirect) {
92 MHD_add_response_header (response, "Location", redirectUrl);
93 status = MHD_HTTP_SEE_OTHER;
94 }
95
96 int ret = MHD_queue_response(connection, status, response);
97 MHD_destroy_response(response);
98 return ret;
99}
static SkString generate_template(SkString source)
Definition: Response.cpp:20
size_t size() const
Definition: SkString.h:131
const char * c_str() const
Definition: SkString.h:133