Delete HttpComposeAttributes.
Bug: webrtc:6424 Change-Id: Ie11def7aed5cf7721e43f23e500bdc593385b2cb Reviewed-on: https://webrtc-review.googlesource.com/33361 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21314}
This commit is contained in:
@ -29,8 +29,6 @@
|
||||
#include "rtc_base/httpcommon.h"
|
||||
#include "rtc_base/messagedigest.h"
|
||||
#include "rtc_base/socketaddress.h"
|
||||
#include "rtc_base/stringencode.h"
|
||||
#include "rtc_base/stringutils.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -223,33 +221,8 @@ inline bool IsEndOfAttributeName(size_t pos, size_t len, const char * data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: unittest for EscapeAttribute and HttpComposeAttributes.
|
||||
|
||||
std::string EscapeAttribute(const std::string& attribute) {
|
||||
const size_t kMaxLength = attribute.length() * 2 + 1;
|
||||
char* buffer = STACK_ARRAY(char, kMaxLength);
|
||||
size_t len = escape(buffer, kMaxLength, attribute.data(), attribute.length(),
|
||||
"\"", '\\');
|
||||
return std::string(buffer, len);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void HttpComposeAttributes(const HttpAttributeList& attributes, char separator,
|
||||
std::string* composed) {
|
||||
std::stringstream ss;
|
||||
for (size_t i=0; i<attributes.size(); ++i) {
|
||||
if (i > 0) {
|
||||
ss << separator << " ";
|
||||
}
|
||||
ss << attributes[i].first;
|
||||
if (!attributes[i].second.empty()) {
|
||||
ss << "=\"" << EscapeAttribute(attributes[i].second) << "\"";
|
||||
}
|
||||
}
|
||||
*composed = ss.str();
|
||||
}
|
||||
|
||||
void HttpParseAttributes(const char * data, size_t len,
|
||||
HttpAttributeList& attributes) {
|
||||
size_t pos = 0;
|
||||
|
@ -22,28 +22,6 @@ namespace rtc {
|
||||
// String Encoding Utilities
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
size_t escape(char * buffer, size_t buflen,
|
||||
const char * source, size_t srclen,
|
||||
const char * illegal, char escape) {
|
||||
RTC_DCHECK(buffer); // TODO(grunell): estimate output size
|
||||
if (buflen <= 0)
|
||||
return 0;
|
||||
|
||||
size_t srcpos = 0, bufpos = 0;
|
||||
while ((srcpos < srclen) && (bufpos + 1 < buflen)) {
|
||||
char ch = source[srcpos++];
|
||||
if ((ch == escape) || ::strchr(illegal, ch)) {
|
||||
if (bufpos + 2 >= buflen)
|
||||
break;
|
||||
buffer[bufpos++] = escape;
|
||||
}
|
||||
buffer[bufpos++] = ch;
|
||||
}
|
||||
|
||||
buffer[bufpos] = '\0';
|
||||
return bufpos;
|
||||
}
|
||||
|
||||
size_t url_decode(char * buffer, size_t buflen,
|
||||
const char * source, size_t srclen) {
|
||||
if (nullptr == buffer)
|
||||
|
@ -23,14 +23,6 @@ namespace rtc {
|
||||
// String Encoding Utilities
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO(nisse): Used only in httpcommon.c. Delete when that file is deleted, or
|
||||
// possibly if the HttpComposeAttributes funtion can be deleted earlier.
|
||||
// Escaping prefixes illegal characters with the escape character. Compact, but
|
||||
// illegal characters still appear in the string.
|
||||
size_t escape(char * buffer, size_t buflen,
|
||||
const char * source, size_t srclen,
|
||||
const char * illegal, char escape);
|
||||
|
||||
// Note: in-place decoding (buffer == source) is allowed.
|
||||
size_t url_decode(char * buffer, size_t buflen,
|
||||
const char * source, size_t srclen);
|
||||
|
Reference in New Issue
Block a user