void CWebSocket::SendContent(LPCSTR szStdResponse, const void *pContent, DWORD dwContentSize) { EMULE_TRY char szBuf[2*1024], acGMT[EP_MAX_HTTPGMTSTR]; CTime timeCurrent = CTime::GetCurrentTime(); struct tm stTm = {0}; acGMT[0] = '\0'; if (timeCurrent.GetGmtTm(&stTm) != NULL) Gmt2HttpStr(acGMT, &stTm); int iLen = wsprintfA( szBuf, "HTTP/1.1 200 OK\r\n" "Date: %s\r\n" // HTTP/1.x response header "Date:" "Server: " WS_SERVER_TOKEN "\r\n" // HTTP/1.x response header "Server:" "%s" "Content-Length: %u\r\n" "Connection: close\r\n\r\n", acGMT, szStdResponse, dwContentSize ); SendData(szBuf, iLen); SendData(pContent, dwContentSize); EMULE_CATCH2 }
void CDevicesDlg::DumpDevice(int nCur) { DeviceInfo& info = m_Devs[nCur]; m_editSN.GetWindowText(info.SN, RC_MAX_SN_LEN); m_editName.GetWindowText(info.Name, RC_MAX_NAME_LEN); m_editDesc.GetWindowText(info.Desc, RC_MAX_DESC_LEN); if (info.Index == -1) info.CreateTime = time(NULL); if (m_chkValid.GetCheck()) { CTime valid; m_dtValid.GetTime(valid); struct tm t; info.ValidTime = mktime(valid.GetGmtTm(&t)); } else { info.ValidTime = 0; } m_listDevs.SetItemText(nCur, 0, info.Name); m_listDevs.SetItemText(nCur, 1, info.SN); m_listDevs.SetItemText(nCur, 2, info.Desc); }
void CWebSocket::SendReply(int iHTTPRespCode) { char acBuf[256], acGMT[EP_MAX_HTTPGMTSTR]; const char *pcHTTPStatus; CTime timeCurrent = CTime::GetCurrentTime(); struct tm stTm = {0}; acGMT[0] = '\0'; if (timeCurrent.GetGmtTm(&stTm) != NULL) Gmt2HttpStr(acGMT, &stTm); // Convert HTTP status code into a HTTP status message // If an unknown status code is sent send "500 Internal Server Error" switch (iHTTPRespCode) { case 304: pcHTTPStatus = "304 Not Modified"; break; case 404: pcHTTPStatus = "404 Not Found"; break; default: pcHTTPStatus = "500 Internal Server Error"; break; } int iLen = wsprintfA( acBuf, "HTTP/1.1 %s\r\n" "Date: %s\r\n" // HTTP/1.x response header "Date:" "Server: " WS_SERVER_TOKEN "\r\n" // HTTP/1.x response header "Server:" "Connection: close\r\n\r\n", pcHTTPStatus, acGMT ); ASSERT(iLen < ARRSIZE(acBuf)); SendData(acBuf, iLen); }