1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

URL class: allowed user-supplied headers to contain a content-type specifier.

This commit is contained in:
jules 2013-09-20 10:18:35 +01:00
parent f887803358
commit ca902e0122
2 changed files with 10 additions and 8 deletions

View file

@ -198,9 +198,11 @@ namespace URLHelpers
data << getMangledParameters (url)
<< url.getPostData();
// just a short text attachment, so use simple url encoding..
headers << "Content-Type: application/x-www-form-urlencoded\r\nContent-length: "
<< (int) data.getDataSize() << "\r\n";
// if the user-supplied headers didn't contain a content-type, add one now..
if (! headers.containsIgnoreCase ("Content-Type"))
headers << "Content-Type: application/x-www-form-urlencoded\r\n";
headers << "Content-length: " << (int) data.getDataSize() << "\r\n";
}
}
@ -320,18 +322,18 @@ bool URL::isProbablyAnEmailAddress (const String& possibleEmailAddress)
InputStream* URL::createInputStream (const bool usePostCommand,
OpenStreamProgressCallback* const progressCallback,
void* const progressCallbackContext,
const String& extraHeaders,
String headers,
const int timeOutMs,
StringPairArray* const responseHeaders) const
{
String headers;
MemoryBlock headersAndPostData;
if (! headers.endsWithChar ('\n'))
headers << "\r\n";
if (usePostCommand)
URLHelpers::createHeadersAndPostData (*this, headers, headersAndPostData);
headers += extraHeaders;
if (! headers.endsWithChar ('\n'))
headers << "\r\n";

View file

@ -251,7 +251,7 @@ public:
InputStream* createInputStream (bool usePostCommand,
OpenStreamProgressCallback* progressCallback = nullptr,
void* progressCallbackContext = nullptr,
const String& extraHeaders = String::empty,
String extraHeaders = String::empty,
int connectionTimeOutMs = 0,
StringPairArray* responseHeaders = nullptr) const;