HTTP Header Bug

void createConnection()
{
    jassert (connection == nullptr);

    if (NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: juceStringToNS (url.toString (! isPost))]
                                                           cachePolicy: NSURLRequestReloadIgnoringLocalCacheData
                                                       timeoutInterval: timeOutMs <= 0 ? 60.0 : (timeOutMs / 1000.0)])
    {
        [req setHTTPMethod: [NSString stringWithUTF8String: httpRequestCmd.toRawUTF8()]];

        StringArray headerLines;
        headerLines.addLines (headers); // (1) ****
        headerLines.removeEmptyStrings (true);

        for (int i = 0; i < headerLines.size(); ++i)
        {
            String key   = headerLines[i].upToFirstOccurrenceOf (":", false, false).trim();
            String value = headerLines[i].fromFirstOccurrenceOf (":", false, false).trim();

            if (key.isNotEmpty() && value.isNotEmpty())
                [req addValue: juceStringToNS (value) forHTTPHeaderField: juceStringToNS (key)];
        }

        if (isPost)
        {
            WebInputStream::createHeadersAndPostData (url, headers, postData); // (2) ****

            if (postData.getSize() > 0)
                [req setHTTPBody: [NSData dataWithBytes: postData.getData()
                                                 length: postData.getSize()]];
        }

        connection = new URLConnectionState (req, numRedirectsToFollow);
    }
}

I’m not getting Content-Type headers added unless I specify them manually in post requests. Is that because headers is used in the line marked (1) and then modified in the line marked (2). Suggest (2) needs to happen before (1)?? Not an expert on the Mac API - so I’m winging it :slight_smile:

This is on Develop

Yep you’re correct, I’ve added this to develop now. Thanks!