[DEV] first post methode availlable
This commit is contained in:
27
test/index.php
Executable file
27
test/index.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// force display of error
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
|
||||
date_default_timezone_set('Europe/Paris');
|
||||
|
||||
|
||||
echo "plop<br/>\n";
|
||||
//echo $_POST;
|
||||
if ( isset($_POST) == true
|
||||
&& empty($_POST) == false) {
|
||||
foreach ($_POST as $key => $value) {
|
||||
echo "key='".$key."' val='".$value."'<br>\n";
|
||||
}
|
||||
}
|
||||
if ( isset($HTTP_RAW_POST_DATA) == true
|
||||
&& empty($HTTP_RAW_POST_DATA) == false) {
|
||||
echo "raw data :'".$HTTP_RAW_POST_DATA."'<br>\n";
|
||||
}
|
||||
|
||||
if ( isset($_SERVER)
|
||||
&& isset($_SERVER["CONTENT_TYPE"]) ) {
|
||||
echo "content Type : '".$_SERVER["CONTENT_TYPE"]."'<br>\n";
|
||||
}
|
||||
|
||||
?>
|
@@ -15,19 +15,39 @@
|
||||
#define __class__ "test"
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
etk::log::setLevel(etk::log::logLevelVerbose);
|
||||
etk::log::setLevel(etk::log::logLevelDebug);
|
||||
APPL_VERBOSE("plop");
|
||||
if (argc > 2) {
|
||||
// client mode ...
|
||||
enet::Http connection;
|
||||
connection.setServer("example.com");
|
||||
|
||||
APPL_INFO("Get data : ");
|
||||
connection.setServer("127.0.0.1");
|
||||
connection.setKeepAlive(true);
|
||||
APPL_INFO("----------------------------");
|
||||
APPL_INFO("GET data : ");
|
||||
if (connection.get("") == false) {
|
||||
APPL_ERROR("can not Get data...");
|
||||
APPL_ERROR("can not GET data...");
|
||||
return -1;
|
||||
}
|
||||
APPL_INFO("data : " << connection.dataString());
|
||||
|
||||
APPL_INFO("----------------------------");
|
||||
APPL_INFO("POST data : ");
|
||||
std::map<std::string, std::string> values;
|
||||
values.insert(std::make_pair<std::string, std::string>("plop", "valuePlop"));
|
||||
if (connection.post("", values) == false) {
|
||||
APPL_ERROR("can not POST data...");
|
||||
return -1;
|
||||
}
|
||||
APPL_INFO("data : " << connection.dataString());
|
||||
|
||||
APPL_INFO("----------------------------");
|
||||
APPL_INFO("POST xml : ");
|
||||
if (connection.post("", /*"application/xml"*/ "text/xml; charset=utf-8", "<plop><string>value1</string></plop>") == false) {
|
||||
APPL_ERROR("can not POST XML data...");
|
||||
return -1;
|
||||
}
|
||||
APPL_INFO("data : " << connection.dataString());
|
||||
|
||||
} else if (argc > 1) {
|
||||
// client mode ...
|
||||
enet::Tcp connection;
|
||||
|
Reference in New Issue
Block a user