コード例 #1
0
ファイル: ob_client_manager.cpp プロジェクト: Abioy/oceanbase
    int ObClientManager::send_request(const ObServer& server, const int32_t pcode, const int32_t version, 
        const int64_t timeout, ObDataBuffer& in_buffer, ObDataBuffer& out_buffer, int64_t& session_id) const
    {
      int rc = OB_SUCCESS;

      ObPacket* response = NULL;
      rc = do_send_request(server, pcode, version, timeout, in_buffer, response);

      // deserialize response packet to out_buffer
      if (OB_SUCCESS == rc && NULL != response)
      {
        session_id = response->get_session_id() ; // TODO
        // copy response's inner_buffer to out_buffer.
        int64_t data_length = response->get_data_length();
        ObDataBuffer* response_buffer = response->get_buffer();
        if (out_buffer.get_remain() < data_length)
        {
          TBSYS_LOG(ERROR, "insufficient memory in out_buffer, remain:%ld, length=%ld",
              out_buffer.get_remain(), data_length);
          rc = OB_ERROR;
        }
        else
        {
          memcpy(out_buffer.get_data() + out_buffer.get_position(),
              response_buffer->get_data() + response_buffer->get_position(),
              data_length);
          out_buffer.get_position() += data_length;
        }

      }

      return rc;
    }
コード例 #2
0
ファイル: winhttp.c プロジェクト: Mikesalinas146/libgit2
static int send_request(winhttp_stream *s, size_t len, int ignore_length)
{
    int request_failed = 0, cert_valid = 1, error = 0;
    DWORD ignore_flags;

    if ((error = do_send_request(s, len, ignore_length)) < 0)
        request_failed = 1;

    if (request_failed) {
        if (GetLastError() != ERROR_WINHTTP_SECURE_FAILURE) {
            giterr_set(GITERR_OS, "failed to send request");
            return -1;
        } else {
            cert_valid = 0;
        }
    }

    giterr_clear();
    if ((error = certificate_check(s, cert_valid)) < 0) {
        if (!giterr_last())
            giterr_set(GITERR_OS, "user cancelled certificate check");

        return error;
    }

    /* if neither the request nor the certificate check returned errors, we're done */
    if (!request_failed)
        return 0;

    ignore_flags =
        SECURITY_FLAG_IGNORE_CERT_CN_INVALID |
        SECURITY_FLAG_IGNORE_CERT_DATE_INVALID |
        SECURITY_FLAG_IGNORE_UNKNOWN_CA;

    if (!WinHttpSetOption(s->request, WINHTTP_OPTION_SECURITY_FLAGS, &ignore_flags, sizeof(ignore_flags))) {
        giterr_set(GITERR_OS, "failed to set security options");
        return -1;
    }

    if ((error = do_send_request(s, len, ignore_length)) < 0)
        giterr_set(GITERR_OS, "failed to send request");

    return error;
}