void XMLHttpRequest::send(Blob* body, ExceptionCode& ec) { if (!initSend(ec)) return; if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) { const String& contentType = getRequestHeader("Content-Type"); if (contentType.isEmpty()) { const String& blobType = body->type(); if (!blobType.isEmpty() && isValidContentType(blobType)) setRequestHeaderInternal("Content-Type", blobType); else { // From FileAPI spec, whenever media type cannot be determined, empty string must be returned. setRequestHeaderInternal("Content-Type", ""); } } m_requestEntityBody = FormData::create(); m_requestEntityBody->appendBlob(body->url()); } createRequest(ec); }
void XMLHttpRequest::send(const String& body, ExceptionCode& ec) { if (!initSend(ec)) return; if (!body.isNull() && m_method != "GET" && m_method != "HEAD" && (m_url.protocolIs("http") || m_url.protocolIs("https"))) { String contentType = getRequestHeader("Content-Type"); if (contentType.isEmpty()) { #if ENABLE(DASHBOARD_SUPPORT) if (usesDashboardBackwardCompatibilityMode()) setRequestHeaderInternal("Content-Type", "application/x-www-form-urlencoded"); else #endif setRequestHeaderInternal("Content-Type", "application/xml"); } m_requestEntityBody = FormData::create(UTF8Encoding().encode(body.characters(), body.length(), EntitiesForUnencodables)); if (m_upload) m_requestEntityBody->setAlwaysStream(true); } createRequest(ec); }
void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec) { if (!initSend(ec)) return; if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) { m_requestEntityBody = FormData::createMultiPart(*body, document()); String contentType = getRequestHeader("Content-Type"); if (contentType.isEmpty()) { contentType = "multipart/form-data; boundary="; contentType += m_requestEntityBody->boundary().data(); setRequestHeaderInternal("Content-Type", contentType); } } createRequest(ec); }
void XMLHttpRequest::send(DOMFormData* body, ExceptionState& exceptionState) { WTF_LOG(Network, "XMLHttpRequest %p send() DOMFormData %p", this, body); if (!initSend(exceptionState)) return; if (areMethodAndURLValidForSend()) { m_requestEntityBody = body->createMultiPartFormData(body->encoding()); if (getRequestHeader("Content-Type").isEmpty()) { AtomicString contentType = AtomicString("multipart/form-data; boundary=", AtomicString::ConstructFromLiteral) + m_requestEntityBody->boundary().data(); setRequestHeaderInternal("Content-Type", contentType); } } createRequest(exceptionState); }
void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec) { if (!initSend(ec)) return; if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) { m_requestEntityBody = FormData::createMultiPart(*(static_cast<FormDataList*>(body)), body->encoding(), document()); m_requestEntityBody->generateFiles(document()); String contentType = getRequestHeader("Content-Type"); if (contentType.isEmpty()) { contentType = makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data()); setRequestHeaderInternal("Content-Type", contentType); } } createRequest(ec); }
void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec) { if (!initSend(ec)) return; if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) { m_requestEntityBody = FormData::createMultiPart(*(static_cast<FormDataList*>(body)), body->encoding(), document()); // We need to ask the client to provide the generated file names if needed. When FormData fills the element // for the file, it could set a flag to use the generated file name, i.e. a package file on Mac. m_requestEntityBody->generateFiles(document()); String contentType = getRequestHeader("Content-Type"); if (contentType.isEmpty()) { contentType = makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data()); setRequestHeaderInternal("Content-Type", contentType); } } createRequest(ec); }
void XMLHttpRequest::send(const String& body, ExceptionState& exceptionState) { WTF_LOG(Network, "XMLHttpRequest %p send() String '%s'", this, body.utf8().data()); if (!initSend(exceptionState)) return; if (!body.isNull() && areMethodAndURLValidForSend()) { String contentType = getRequestHeader("Content-Type"); if (contentType.isEmpty()) { setRequestHeaderInternal("Content-Type", "text/plain;charset=UTF-8"); } else { replaceCharsetInMediaType(contentType, "UTF-8"); m_requestHeaders.set("Content-Type", AtomicString(contentType)); } m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, WTF::EntitiesForUnencodables)); if (m_upload) m_requestEntityBody->setAlwaysStream(true); } createRequest(exceptionState); }