// // Copyright 2013 Google Inc. All Rights Reserved. // //#define LOG_NDEBUG 0 #define LOG_TAG "HTTPUtil" #include #include "HTTPUtil.h" #include "HTTPSource.h" //#include #include #include namespace android { bool DoSoapAction(const String8& url, const String8& action, const String8& xmlData, Vector* response) { KeyedVector headers; headers.add(String8("Content-Type"), String8("text/xml; charset=utf-8")); headers.add(String8("Proxy-Connection"), String8("Keep-Alive")); headers.add(String8("Pragma"), String8("no-cache")); if (!action.isEmpty()) { headers.add(String8("SOAPAction"), action); } sp source(new HTTPSource()); if (source->connect(url.string(), &headers, 0, xmlData.string()) != OK) { HI_LOGE("Failed in connect()"); return false; } off64_t size; if (source->getSize(&size) != OK) { HI_LOGE("Failed in getSize()"); return false; } Vector responseBuffer; responseBuffer.setCapacity(size); ssize_t read = source->readAt(0, responseBuffer.editArray(), size); (void)read; source->disconnect(); response->appendArray(responseBuffer.array(), size); return true; } } // namespace android