コード例 #1
0
void ReplayTransport::recordInput(Transport* transport, const char *filename) {
  ASSERT(transport);

  Hdf hdf;
  hdf["thread"] = (int64)pthread_self();
  hdf["get"] = (transport->getMethod() == GET);
  hdf["url"] = transport->getUrl();
  hdf["remote_host"] = transport->getRemoteHost();

  transport->getHeaders(m_requestHeaders);
  int index = 0;
  for (HeaderMap::const_iterator iter = m_requestHeaders.begin();
       iter != m_requestHeaders.end(); ++iter) {
    for (unsigned int i = 0; i < iter->second.size(); i++) {
      Hdf header = hdf["headers"][index++];
      header["name"] = iter->first;
      header["value"] = iter->second[i];
    }
  }

  int size;
  const void *data = transport->getPostData(size);
  if (size) {
    int len;
    char *encoded = string_uuencode((const char *)data, size, len);
    hdf["post"] = encoded;
    free(encoded);
  } else {
    hdf["post"] = "";
  }

  hdf.write(filename);
}
コード例 #2
0
ファイル: replay-transport.cpp プロジェクト: Orvid/hhvm
void ReplayTransport::recordInput(Transport* transport, const char *filename) {
  assert(transport);

  Hdf hdf;

  char buf[32];
  snprintf(buf, sizeof(buf), "%u", Process::GetProcessId());
  hdf["pid"] = std::string(buf);
#ifdef _MSC_VER
  snprintf(buf, sizeof(buf), "%" PRIx64,
    (int64_t)pthread_getw32threadid_np(Process::GetThreadId()));
#else
  snprintf(buf, sizeof(buf), "%" PRIx64, (int64_t)Process::GetThreadId());
#endif
  hdf["tid"] = std::string(buf);
  snprintf(buf, sizeof(buf), "%u", Process::GetThreadPid());
  hdf["tpid"] = std::string(buf);

  hdf["cmd"] = static_cast<int>(transport->getMethod());
  hdf["url"] = transport->getUrl();
  hdf["remote_host"] = transport->getRemoteHost();
  hdf["remote_port"] = transport->getRemotePort();

  transport->getHeaders(m_requestHeaders);
  int index = 0;
  for (HeaderMap::const_iterator iter = m_requestHeaders.begin();
       iter != m_requestHeaders.end(); ++iter) {
    for (unsigned int i = 0; i < iter->second.size(); i++) {
      Hdf header = hdf["headers"][index++];
      header["name"] = iter->first;
      header["value"] = iter->second[i];
    }
  }

  int size;
  const void *data = transport->getPostData(size);
  if (size) {
    String encoded = string_uuencode((const char *)data, size);
    hdf["post"] = encoded.get()->data();
  } else {
    hdf["post"] = "";
  }

  hdf.write(filename);
}
コード例 #3
0
void ReplayTransport::recordInput(Transport* transport, const char *filename) {
  ASSERT(transport);

  Hdf hdf;

  char buf[32];
  snprintf(buf, sizeof(buf), "%u", Process::GetProcessId());
  hdf["pid"] = string(buf);
  snprintf(buf, sizeof(buf), "%llx", (int64)Process::GetThreadId());
  hdf["tid"] = string(buf);
  snprintf(buf, sizeof(buf), "%u", Process::GetThreadPid());
  hdf["tpid"] = string(buf);

  hdf["cmd"] = transport->getMethod();
  hdf["url"] = transport->getUrl();
  hdf["remote_host"] = transport->getRemoteHost();
  hdf["remote_port"] = transport->getRemotePort();

  transport->getHeaders(m_requestHeaders);
  int index = 0;
  for (HeaderMap::const_iterator iter = m_requestHeaders.begin();
       iter != m_requestHeaders.end(); ++iter) {
    for (unsigned int i = 0; i < iter->second.size(); i++) {
      Hdf header = hdf["headers"][index++];
      header["name"] = iter->first;
      header["value"] = iter->second[i];
    }
  }

  int size;
  const void *data = transport->getPostData(size);
  if (size) {
    int len;
    char *encoded = string_uuencode((const char *)data, size, len);
    hdf["post"] = encoded;
    free(encoded);
  } else {
    hdf["post"] = "";
  }

  hdf.write(filename);
}