code style
This commit is contained in:
@@ -130,8 +130,8 @@ void AttributedItem::mergeAttributes(map<string, string>* attributes) const {
|
||||
}
|
||||
}
|
||||
|
||||
void AttributedItem::dumpAttribute(bool prependFieldSeparator, OutputFormat outputFormat, const string& name, ostream* output)
|
||||
const {
|
||||
void AttributedItem::dumpAttribute(bool prependFieldSeparator, OutputFormat outputFormat, const string& name,
|
||||
ostream* output) const {
|
||||
if (outputFormat & OF_JSON) {
|
||||
appendJson(prependFieldSeparator, name, getAttribute(name), false, output);
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -426,12 +426,12 @@ class SingleDataField : public DataField {
|
||||
size_t getCount(PartType partType = pt_any, const char* fieldName = nullptr) const override;
|
||||
|
||||
// @copydoc
|
||||
virtual string getName(ssize_t fieldIndex) const override {
|
||||
string getName(ssize_t fieldIndex) const override {
|
||||
return isIgnored() || fieldIndex > 0 ? "" : m_name;
|
||||
}
|
||||
|
||||
// @copydoc
|
||||
virtual const SingleDataField* getField(ssize_t fieldIndex) const override {
|
||||
const SingleDataField* getField(ssize_t fieldIndex) const override {
|
||||
if (isIgnored() || fieldIndex > 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -359,8 +359,8 @@ result_t DateTimeDataType::readSymbols(size_t offset, size_t length, const Symbo
|
||||
return RESULT_ERR_INVALID_POS;
|
||||
}
|
||||
// number of minutes since 01.01.2009
|
||||
minutes |= symbol*(1<<(8*i));
|
||||
if (i<3) {
|
||||
minutes |= symbol*(1 << (8*i));
|
||||
if (i < 3) {
|
||||
break;
|
||||
}
|
||||
int mjd = static_cast<int>(minutes/(24*60)) + 54832; // 01.01.2009
|
||||
@@ -424,7 +424,7 @@ result_t DateTimeDataType::writeSymbols(size_t offset, size_t length, istringstr
|
||||
if (length == 4 && i == 2 && !m_hasTime) {
|
||||
continue; // skip weekday in between
|
||||
}
|
||||
if (input->eof() || !getline(*input, token, m_hasTime && i==2 ? ' ' : '.')) {
|
||||
if (input->eof() || !getline(*input, token, m_hasTime && i == 2 ? ' ' : '.')) {
|
||||
return RESULT_ERR_EOF; // incomplete
|
||||
}
|
||||
if (!hasFlag(REQ) && token == NULL_VALUE) {
|
||||
@@ -464,7 +464,7 @@ result_t DateTimeDataType::writeSymbols(size_t offset, size_t length, istringstr
|
||||
index = start + incr;
|
||||
i = 1;
|
||||
type = 1;
|
||||
skip = true; // switch to second pass for parsing the time
|
||||
skip = true; // switch to second pass for parsing the time
|
||||
} else {
|
||||
// calculate local week day
|
||||
int daysSinceSunday = (mjd + 3) % 7; // Sun=0
|
||||
@@ -546,7 +546,7 @@ result_t DateTimeDataType::writeSymbols(size_t offset, size_t length, istringstr
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: // date and time in store phase
|
||||
case 3: // date and time in store phase
|
||||
value = lastLast & 0xff;
|
||||
last = lastLast >> 8;
|
||||
break;
|
||||
@@ -677,7 +677,7 @@ result_t NumberDataType::derive(int divisor, size_t bitCount, const NumberDataTy
|
||||
|
||||
result_t NumberDataType::getMinMax(bool getMax, const OutputFormat outputFormat, ostream* output) const {
|
||||
size_t length;
|
||||
if (m_bitCount<8) {
|
||||
if (m_bitCount < 8) {
|
||||
length = 1;
|
||||
} else {
|
||||
length = m_bitCount/8;
|
||||
@@ -1135,7 +1135,7 @@ DataTypeList* DataTypeList::getInstance() {
|
||||
void DataTypeList::dump(OutputFormat outputFormat, bool appendDivisor, ostream* output) const {
|
||||
bool json = outputFormat & OF_JSON;
|
||||
string sep = "\n";
|
||||
for (const auto &it: m_typesById) {
|
||||
for (const auto &it : m_typesById) {
|
||||
const DataType *dataType = it.second;
|
||||
if (dataType->hasFlag(DUP)) {
|
||||
continue;
|
||||
|
||||
@@ -437,8 +437,8 @@ class NumberDataType : public DataType {
|
||||
NumberDataType(const string& id, size_t bitCount, uint16_t flags, unsigned int replacement,
|
||||
unsigned int minValue, unsigned int maxValue, int divisor,
|
||||
const NumberDataType* baseType = nullptr)
|
||||
: DataType(id, bitCount, flags|NUM, replacement), m_minValue(minValue), m_maxValue(maxValue), m_divisor(divisor==0 ? 1 : divisor),
|
||||
m_precision(calcPrecision(divisor)), m_firstBit(0), m_baseType(baseType) {}
|
||||
: DataType(id, bitCount, flags|NUM, replacement), m_minValue(minValue), m_maxValue(maxValue),
|
||||
m_divisor(divisor == 0 ? 1 : divisor), m_precision(calcPrecision(divisor)), m_firstBit(0), m_baseType(baseType) {}
|
||||
|
||||
/**
|
||||
* Constructs a new instance for less than 8 bits.
|
||||
@@ -452,8 +452,8 @@ class NumberDataType : public DataType {
|
||||
*/
|
||||
NumberDataType(const string& id, size_t bitCount, uint16_t flags, unsigned int replacement,
|
||||
int16_t firstBit, int divisor, const NumberDataType* baseType = nullptr)
|
||||
: DataType(id, bitCount, flags|NUM, replacement), m_minValue(0), m_maxValue((1 << bitCount)-1), m_divisor(divisor==0 ? 1 : divisor),
|
||||
m_precision(0), m_firstBit(firstBit), m_baseType(baseType) {}
|
||||
: DataType(id, bitCount, flags|NUM, replacement), m_minValue(0), m_maxValue((1 << bitCount)-1),
|
||||
m_divisor(divisor == 0 ? 1 : divisor), m_precision(0), m_firstBit(firstBit), m_baseType(baseType) {}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
|
||||
+12
-10
@@ -79,8 +79,8 @@ namespace ebusd {
|
||||
Device::Device(const char* name, bool checkDevice, unsigned int latency, bool readOnly, bool initialSend,
|
||||
bool enhancedProto)
|
||||
: m_name(name), m_checkDevice(checkDevice),
|
||||
m_latency(HOST_LATENCY_MS+(enhancedProto?ENHANCED_LATENCY_MS:0)+latency), m_readOnly(readOnly), m_initialSend(initialSend),
|
||||
m_enhancedProto(enhancedProto), m_fd(-1), m_listener(nullptr), m_arbitrationMaster(SYN),
|
||||
m_latency(HOST_LATENCY_MS+(enhancedProto?ENHANCED_LATENCY_MS:0)+latency), m_readOnly(readOnly),
|
||||
m_initialSend(initialSend), m_enhancedProto(enhancedProto), m_fd(-1), m_listener(nullptr), m_arbitrationMaster(SYN),
|
||||
m_arbitrationCheck(false), m_bufSize(((MAX_LEN+1+3)/4)*4), m_bufLen(0), m_bufPos(0),
|
||||
m_extraFatures(0), m_infoId(0xff), m_infoLen(0), m_infoPos(0) {
|
||||
m_buffer = reinterpret_cast<symbol_t*>(malloc(m_bufSize));
|
||||
@@ -184,7 +184,7 @@ result_t Device::requestEnhancedInfo(symbol_t infoId) {
|
||||
if (!m_enhancedProto || m_extraFatures == 0 || infoId == 0xff) {
|
||||
return RESULT_ERR_INVALID_ARG;
|
||||
}
|
||||
for (unsigned int i=0; i<4; i++) {
|
||||
for (unsigned int i = 0; i < 4; i++) {
|
||||
if (m_infoId == 0xff) {
|
||||
break;
|
||||
}
|
||||
@@ -602,7 +602,7 @@ bool Device::read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrati
|
||||
break;
|
||||
case ENH_RES_INFO:
|
||||
if (m_infoLen == 0) {
|
||||
if (data<=16) { // max length
|
||||
if (data <= 16) { // max length
|
||||
m_infoLen = data;
|
||||
m_infoPos = 0;
|
||||
}
|
||||
@@ -611,9 +611,10 @@ bool Device::read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrati
|
||||
if (m_infoPos >= m_infoLen) {
|
||||
unsigned int val;
|
||||
ostringstream stream;
|
||||
switch ((m_infoLen<<8) | m_infoId) {
|
||||
switch ((m_infoLen << 8) | m_infoId) {
|
||||
case 0x0200:
|
||||
stream << "firmware " << static_cast<unsigned>(m_infoBuf[0]) << "." << std::hex << static_cast<unsigned>(m_infoBuf[1]);
|
||||
stream << "firmware " << static_cast<unsigned>(m_infoBuf[0]) << "." << std::hex
|
||||
<< static_cast<unsigned>(m_infoBuf[1]);
|
||||
break;
|
||||
case 0x0901:
|
||||
case 0x0802:
|
||||
@@ -624,12 +625,12 @@ bool Device::read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrati
|
||||
}
|
||||
break;
|
||||
case 0x0203:
|
||||
val = (static_cast<unsigned>(m_infoBuf[0])<<8) | static_cast<unsigned>(m_infoBuf[1]);
|
||||
val = (static_cast<unsigned>(m_infoBuf[0]) << 8) | static_cast<unsigned>(m_infoBuf[1]);
|
||||
stream << "temperature " << static_cast<unsigned>(val) << " °C";
|
||||
m_enhInfoTemperature = stream.str();
|
||||
break;
|
||||
case 0x0204:
|
||||
val = (static_cast<unsigned>(m_infoBuf[0])<<8) | static_cast<unsigned>(m_infoBuf[1]);
|
||||
val = (static_cast<unsigned>(m_infoBuf[0]) << 8) | static_cast<unsigned>(m_infoBuf[1]);
|
||||
stream << "supply voltage " << static_cast<unsigned>(val) << " mV";
|
||||
m_enhInfoSupplyVoltage = stream.str();
|
||||
break;
|
||||
@@ -640,8 +641,9 @@ bool Device::read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrati
|
||||
m_enhInfoBusVoltage = stream.str();
|
||||
break;
|
||||
default:
|
||||
stream << "unknown 0x" << std::hex << std::setfill('0') << std::setw(2) << static_cast<unsigned>(m_infoId)
|
||||
<< ", len " << std::dec << std::setw(0) << static_cast<unsigned>(m_infoPos);
|
||||
stream << "unknown 0x" << std::hex << std::setfill('0') << std::setw(2)
|
||||
<< static_cast<unsigned>(m_infoId) << ", len " << std::dec << std::setw(0)
|
||||
<< static_cast<unsigned>(m_infoPos);
|
||||
break;
|
||||
}
|
||||
m_listener->notifyStatus(false, ("extra info: "+stream.str()).c_str());
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <netdb.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include "lib/ebus/result.h"
|
||||
#include "lib/ebus/symbol.h"
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ bool FileReader::matches(const string& input, const string& search, bool ignoreC
|
||||
} else {
|
||||
found = true;
|
||||
}
|
||||
if (from==to) {
|
||||
if (from == to) {
|
||||
return true; // empty pattern matches everything
|
||||
}
|
||||
size_t nextStart = to+1;
|
||||
@@ -150,11 +150,11 @@ bool FileReader::matches(const string& input, const string& search, bool ignoreC
|
||||
if (matchStart) {
|
||||
from++;
|
||||
}
|
||||
bool matchEnd = from<to && search[to-1] == '$';
|
||||
bool matchEnd = from < to && search[to-1] == '$';
|
||||
if (matchEnd) {
|
||||
to--;
|
||||
}
|
||||
if (matchEnd && matchStart && from==to) { // pattern is "^$"
|
||||
if (matchEnd && matchStart && from == to) { // pattern is "^$"
|
||||
if (input.empty()) {
|
||||
return true;
|
||||
}
|
||||
@@ -189,7 +189,7 @@ bool FileReader::matches(const string& input, const string& search, bool ignoreC
|
||||
}
|
||||
if (prefix.length() <= checkEnd) {
|
||||
if (matchStart) {
|
||||
if (input.substr(0, prefix.length()) == prefix && (!matchEnd || prefix.length()==checkEnd)) {
|
||||
if (input.substr(0, prefix.length()) == prefix && (!matchEnd || prefix.length() == checkEnd)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
||||
+15
-11
@@ -483,11 +483,11 @@ result_t Message::create(const string& filename, const DataFieldTemplates* templ
|
||||
}
|
||||
Message* message;
|
||||
if (chainIds.size() > 1) {
|
||||
message = new ChainedMessage(filename, useCircuit, level, name, isWrite, *row, srcAddress, dstAddress, id, chainIds,
|
||||
chainLengths, data, index == 0, pollPriority, condition);
|
||||
message = new ChainedMessage(filename, useCircuit, level, name, isWrite, *row, srcAddress, dstAddress, id,
|
||||
chainIds, chainLengths, data, index == 0, pollPriority, condition);
|
||||
} else {
|
||||
message = new Message(filename, useCircuit, level, name, isWrite, isPassive, *row, srcAddress, dstAddress, id, data,
|
||||
index == 0, pollPriority, condition);
|
||||
message = new Message(filename, useCircuit, level, name, isWrite, isPassive, *row, srcAddress, dstAddress, id,
|
||||
data, index == 0, pollPriority, condition);
|
||||
}
|
||||
messages->push_back(message);
|
||||
index++;
|
||||
@@ -853,7 +853,8 @@ void Message::dumpHeader(const vector<string>* fieldNames, ostream* output) {
|
||||
}
|
||||
}
|
||||
|
||||
void Message::dump(const vector<string>* fieldNames, bool withConditions, OutputFormat outputFormat, ostream* output) const {
|
||||
void Message::dump(const vector<string>* fieldNames, bool withConditions, OutputFormat outputFormat, ostream* output)
|
||||
const {
|
||||
// not to be used together with OF_JSON
|
||||
bool first = true;
|
||||
if (fieldNames == nullptr) {
|
||||
@@ -880,7 +881,8 @@ void Message::dump(const vector<string>* fieldNames, bool withConditions, Output
|
||||
}
|
||||
}
|
||||
|
||||
void Message::dumpField(const string& fieldName, bool withConditions, OutputFormat outputFormat, ostream* output) const {
|
||||
void Message::dumpField(const string& fieldName, bool withConditions, OutputFormat outputFormat, ostream* output)
|
||||
const {
|
||||
if (fieldName == "type") {
|
||||
if (withConditions && m_condition != nullptr) {
|
||||
m_condition->dump(false, output);
|
||||
@@ -969,7 +971,7 @@ void Message::decodeJson(bool leadingSeparator, bool appendDirectionCondition, b
|
||||
if (outputFormat & OF_ALL_ATTRS) {
|
||||
*output << ",\n \"filename\": \"" << m_filename << "\"";
|
||||
*output << ",\n \"level\": \"" << getLevel() << "\"";
|
||||
if (getPollPriority()>0) {
|
||||
if (getPollPriority() > 0) {
|
||||
*output << ",\n \"pollprio\": " << setw(0) << dec << getPollPriority();
|
||||
}
|
||||
if (isConditional()) {
|
||||
@@ -1278,7 +1280,8 @@ result_t ChainedMessage::combineLastParts() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void ChainedMessage::dumpField(const string& fieldName, bool withConditions, OutputFormat outputFormat, ostream* output) const {
|
||||
void ChainedMessage::dumpField(const string& fieldName, bool withConditions, OutputFormat outputFormat, ostream* output)
|
||||
const {
|
||||
if (fieldName != "id") {
|
||||
Message::dumpField(fieldName, withConditions, outputFormat, output);
|
||||
return;
|
||||
@@ -2164,10 +2167,11 @@ result_t MessageMap::readConditions(const string& filename, string* types, strin
|
||||
|
||||
bool MessageMap::extractDefaultsFromFilename(const string& filename, map<string, string>* defaults,
|
||||
symbol_t* destAddress, unsigned int* software, unsigned int* hardware) const {
|
||||
// check filename to match (glob style with optionals in brackets): ZZ.[ID.][*.][CIRCUIT.[?.]][*.][HW????.][*.][SW????.][*.]csv
|
||||
// check filename to match (glob style with optionals in brackets):
|
||||
// ZZ.[ID.][*.][CIRCUIT.[?.]][*.][HW????.][*.][SW????.][*.]csv
|
||||
// ZZ is the address, ID is the 5 char identifier (reduced by trailing 0 one by one for finding a match), CIRCUIT is
|
||||
// the optional circuit name, ? behind the circuit name is the circuit number suffix (when having more than one of these),
|
||||
// ???? behind HW is the hardware version, ???? behind SW is the software version
|
||||
// the optional circuit name, ? behind the circuit name is the circuit number suffix (when having more than one of
|
||||
// these), ???? behind HW is the hardware version, ???? behind SW is the software version
|
||||
string ident, circuit, suffix;
|
||||
unsigned int sw = UINT_MAX, hw = UINT_MAX;
|
||||
string remain = filename;
|
||||
|
||||
@@ -586,7 +586,8 @@ class Message : public AttributedItem {
|
||||
* @param outputFormat the @a OutputFormat options.
|
||||
* @param output the @a ostream to append the formatted value to.
|
||||
*/
|
||||
virtual void dumpField(const string& fieldName, bool withConditions, OutputFormat outputFormat, ostream* output) const;
|
||||
virtual void dumpField(const string& fieldName, bool withConditions, OutputFormat outputFormat, ostream* output)
|
||||
const;
|
||||
|
||||
/**
|
||||
* Decode the message from the last stored data in JSON format.
|
||||
@@ -767,7 +768,8 @@ class ChainedMessage : public Message {
|
||||
|
||||
protected:
|
||||
// @copydoc
|
||||
void dumpField(const string& fieldName, bool withConditions, OutputFormat outputFormat, ostream* output) const override;
|
||||
void dumpField(const string& fieldName, bool withConditions, OutputFormat outputFormat, ostream* output) const
|
||||
override;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
*/
|
||||
|
||||
#include "lib/utils/httpclient.h"
|
||||
#include "lib/utils/log.h"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#include <csignal>
|
||||
#include "lib/utils/log.h"
|
||||
|
||||
namespace ebusd {
|
||||
|
||||
@@ -59,7 +59,7 @@ bool isError(const char* call, long result, long expected) {
|
||||
if (checkError(call)) {
|
||||
return true;
|
||||
}
|
||||
if (result!=expected) {
|
||||
if (result != expected) {
|
||||
logError(lf_network, "HTTP %s: invalid result %d", call, result);
|
||||
return true;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ ssize_t SSLSocket::send(const char* data, size_t len) {
|
||||
do {
|
||||
size_t part = 0;
|
||||
int res = BIO_write_ex(m_bio, data, len, &part);
|
||||
if (res==1) {
|
||||
if (res == 1) {
|
||||
return static_cast<signed>(part);
|
||||
}
|
||||
if (!BIO_should_retry(m_bio)) {
|
||||
@@ -88,15 +88,15 @@ ssize_t SSLSocket::send(const char* data, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
usleep(SLEEP_NANOS);
|
||||
} while (time(nullptr)<m_until);
|
||||
return -1; // timeout
|
||||
} while (time(nullptr) < m_until);
|
||||
return -1; // timeout
|
||||
}
|
||||
|
||||
ssize_t SSLSocket::recv(char* data, size_t len) {
|
||||
do {
|
||||
size_t part = 0;
|
||||
int res = BIO_read_ex(m_bio, data, len, &part);
|
||||
if (res==1) {
|
||||
if (res == 1) {
|
||||
return static_cast<signed>(part);
|
||||
}
|
||||
if (!BIO_should_retry(m_bio)) {
|
||||
@@ -106,12 +106,12 @@ ssize_t SSLSocket::recv(char* data, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
usleep(SLEEP_NANOS);
|
||||
} while (time(nullptr)<m_until);
|
||||
return -1; // timeout
|
||||
} while (time(nullptr) < m_until);
|
||||
return -1; // timeout
|
||||
}
|
||||
|
||||
bool SSLSocket::isValid() {
|
||||
return time(nullptr)<m_until && !BIO_eof(m_bio);
|
||||
return time(nullptr) < m_until && !BIO_eof(m_bio);
|
||||
}
|
||||
|
||||
// general switch for future insecure option
|
||||
@@ -123,14 +123,14 @@ SSLSocket* SSLSocket::connect(const string& host, const uint16_t& port, bool htt
|
||||
ostringstream ostr;
|
||||
ostr << host << ':' << static_cast<unsigned>(port);
|
||||
const string hostPort = ostr.str();
|
||||
time_t until = time(nullptr) + (timeout<=2 ? 2 : timeout); // at least 2 seconds
|
||||
time_t until = time(nullptr) + (timeout <= 2 ? 2 : timeout); // at least 2 seconds
|
||||
if (!https) {
|
||||
do {
|
||||
bio = BIO_new_connect(hostPort.c_str());
|
||||
if (isError("connect", bio)) {
|
||||
break;
|
||||
}
|
||||
BIO_set_nbio(bio, 1); // set non-blocking
|
||||
BIO_set_nbio(bio, 1); // set non-blocking
|
||||
return new SSLSocket(nullptr, bio, until);
|
||||
} while (false);
|
||||
} else {
|
||||
@@ -157,7 +157,7 @@ SSLSocket* SSLSocket::connect(const string& host, const uint16_t& port, bool htt
|
||||
if (isError("conn_hostname", BIO_set_conn_hostname(bio, hostPort.c_str()), 1)) {
|
||||
break;
|
||||
}
|
||||
BIO_set_nbio(bio, 1); // set non-blocking
|
||||
BIO_set_nbio(bio, 1); // set non-blocking
|
||||
BIO_get_ssl(bio, &ssl);
|
||||
if (isError("get_ssl", ssl)) {
|
||||
break;
|
||||
@@ -217,13 +217,13 @@ void HttpClient::initialize() {
|
||||
s_initialized = true;
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
signal(SIGPIPE, SIG_IGN); // needed to avoid SIGPIPE when writing to a closed pipe
|
||||
signal(SIGPIPE, SIG_IGN); // needed to avoid SIGPIPE when writing to a closed pipe
|
||||
}
|
||||
#else // HAVE_SSL
|
||||
#else // HAVE_SSL
|
||||
void HttpClient::initialize() {
|
||||
// empty
|
||||
}
|
||||
#endif // HAVE_SSL
|
||||
#endif // HAVE_SSL
|
||||
|
||||
bool HttpClient::parseUrl(const string& url, string* proto, string* host, uint16_t* port, string* uri) {
|
||||
size_t hostPos = url.find("://");
|
||||
@@ -273,7 +273,8 @@ bool HttpClient::parseUrl(const string& url, string* proto, string* host, uint16
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HttpClient::connect(const string& host, const uint16_t port, const bool https, const string& userAgent, const int timeout) {
|
||||
bool HttpClient::connect(const string& host, const uint16_t port, bool https, const string& userAgent,
|
||||
const int timeout) {
|
||||
disconnect();
|
||||
#ifdef HAVE_SSL
|
||||
m_socket = SSLSocket::connect(host, port, https, timeout);
|
||||
@@ -445,7 +446,7 @@ bool HttpClient::request(const string& method, const string& uri, const string&
|
||||
|
||||
size_t HttpClient::readUntil(const string& delim, const size_t length, string* result) {
|
||||
if (!m_buffer) {
|
||||
m_buffer = reinterpret_cast<char*>(malloc(1024+1)); // 1 extra for final terminator
|
||||
m_buffer = reinterpret_cast<char*>(malloc(1024+1)); // 1 extra for final terminator
|
||||
if (!m_buffer) {
|
||||
return string::npos;
|
||||
}
|
||||
|
||||
@@ -106,11 +106,11 @@ class SSLSocket {
|
||||
|
||||
#define SocketClass SSLSocket
|
||||
|
||||
#else // HAVE_SSL
|
||||
#else // HAVE_SSL
|
||||
|
||||
#define SocketClass TCPSocket
|
||||
|
||||
#endif // HAVE_SSL
|
||||
#endif // HAVE_SSL
|
||||
|
||||
/**
|
||||
* Helper class for handling HTTP client requests.
|
||||
@@ -160,7 +160,7 @@ class HttpClient {
|
||||
* @param userAgent the optional user agent to send in the request header.
|
||||
* @return true on success, false on connect failure.
|
||||
*/
|
||||
bool connect(const string& host, uint16_t port, const bool https = false, const string& userAgent = "", int timeout = 5);
|
||||
bool connect(const string& host, uint16_t port, bool https = false, const string& userAgent = "", int timeout = 5);
|
||||
|
||||
/**
|
||||
* Re-connect to the last specified server.
|
||||
|
||||
Reference in New Issue
Block a user