| 32 | } |
| 33 | |
| 34 | bool HttpStreamClient::connect() { |
| 35 | // If already connected, return true |
| 36 | if (isConnected()) { |
| 37 | return true; |
| 38 | } |
| 39 | |
| 40 | // Reset HTTP state |
| 41 | mHttpHeaderSent = false; |
| 42 | mHttpHeaderReceived = false; |
| 43 | |
| 44 | // Connect native socket |
| 45 | if (!mNativeClient->connect()) { |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | // Send HTTP POST request header |
| 50 | if (!sendHttpRequestHeader()) { |
| 51 | mNativeClient->disconnect(); |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | // Read HTTP response header |
| 56 | if (!readHttpResponseHeader()) { |
| 57 | mNativeClient->disconnect(); |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | // Mark connection as established in base class |
| 62 | mConnection.onConnected(); |
| 63 | |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | void HttpStreamClient::disconnect() { |
| 68 | if (mNativeClient) { |
nothing calls this directly
no test coverage detected