| 59 | // data stream overrides |
| 60 | |
| 61 | int HttpStream::write(const uint8_t *value, int size) { |
| 62 | gsl_Expects(size >= 0); |
| 63 | if (size == 0) { |
| 64 | return 0; |
| 65 | } |
| 66 | if (!IsNullOrEmpty(value)) { |
| 67 | if (!started_) { |
| 68 | std::lock_guard<std::mutex> lock(mutex_); |
| 69 | if (!started_) { |
| 70 | callback_.ptr = &http_callback_; |
| 71 | callback_.pos = 0; |
| 72 | http_client_->setUploadCallback(&callback_); |
| 73 | http_client_future_ = std::async(std::launch::async, submit_client, http_client_); |
| 74 | started_ = true; |
| 75 | } |
| 76 | } |
| 77 | http_callback_.process(value, size); |
| 78 | return size; |
| 79 | } else { |
| 80 | return -1; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | int HttpStream::read(uint8_t *buf, int buflen) { |
| 85 | gsl_Expects(buflen >= 0); |