@@ -149,8 +149,8 @@ std::string HTTPMessage::getStrElement(char delim) {
149149 return " " ;
150150
151151 // Grab the std::string from the byte buffer up to the delimiter
152- char * str = new char [size];
153- bzero (str, size);
152+ auto str = new char [size];
153+ memset (str, 0x00 , size);
154154 getBytes ((byte*)str, size);
155155 str[size - 1 ] = 0x00 ; // NULL termination
156156 ret.assign (str);
@@ -168,7 +168,8 @@ std::string HTTPMessage::getStrElement(char delim) {
168168 * Parse headers will move the read position past the blank line that signals the end of the headers
169169 */
170170void HTTPMessage::parseHeaders () {
171- std::string hline = " " , app = " " ;
171+ std::string hline = " " ;
172+ std::string app = " " ;
172173
173174 // Get the first header
174175 hline = getLine ();
@@ -208,10 +209,9 @@ bool HTTPMessage::parseBody() {
208209 // contentLen should NOT exceed the remaining number of bytes in the buffer
209210 // Add 1 to bytesRemaining so it includes the byte at the current read position
210211 if (contentLen > bytesRemaining () + 1 ) {
211- /*
212212 // If it exceeds, read only up to the number of bytes remaining
213- dataLen = bytesRemaining();
214- */
213+ // dataLen = bytesRemaining();
214+
215215 // If it exceeds, there's a potential security issue and we can't reliably parse
216216 std::stringstream pes;
217217 pes << " Content-Length (" << hlenstr << " ) is greater than remaining bytes (" << bytesRemaining () << " )" ;
@@ -243,8 +243,9 @@ bool HTTPMessage::parseBody() {
243243 *
244244 * @param string containing formatted header: value
245245 */
246- void HTTPMessage::addHeader (std::string line) {
247- std::string key = " " , value = " " ;
246+ void HTTPMessage::addHeader (std::string const line) {
247+ std::string key = " " ;
248+ std::string value = " " ;
248249 size_t kpos;
249250 int i = 0 ;
250251 kpos = line.find (' :' );
@@ -271,7 +272,7 @@ void HTTPMessage::addHeader(std::string line) {
271272 * @param key String representation of the Header Key
272273 * @param value String representation of the Header value
273274 */
274- void HTTPMessage::addHeader (std::string key, std::string value) {
275+ void HTTPMessage::addHeader (std::string const key, std::string const value) {
275276 headers->insert (std::pair<std::string, std::string>(key, value));
276277}
277278
@@ -282,7 +283,7 @@ void HTTPMessage::addHeader(std::string key, std::string value) {
282283 * @param key String representation of the Header Key
283284 * @param value Integer representation of the Header value
284285 */
285- void HTTPMessage::addHeader (std::string key, int value) {
286+ void HTTPMessage::addHeader (std::string const key, int value) {
286287 std::stringstream sz;
287288 sz << value;
288289 headers->insert (std::pair<std::string, std::string>(key, sz.str ()));
@@ -294,7 +295,7 @@ void HTTPMessage::addHeader(std::string key, int value) {
294295 *
295296 * @param key Key to identify the header
296297 */
297- std::string HTTPMessage::getHeaderValue (std::string key) {
298+ std::string HTTPMessage::getHeaderValue (std::string const key) {
298299
299300 char c;
300301 std::string key_lower = " " ;
0 commit comments