Ejemplo n.º 1
0
void CHttpRequest::SetRField(const CString& Name, const CString& Value) {
    CStringTable Table = m_RFields.FindElement(Name);
    // Table.Set(g_strName, Name);
    // Table.Set(g_strValue, Value);
    Table.Set(Name, Value);
    m_RFields.Set(Name, Table);
}
Ejemplo n.º 2
0
void CHttpRequest::MakeRequestString(const float HttpVersion, CString * pRequest) {
    
    pRequest->SetSize(128 + m_HttpFields.GetSize() * 32);
    (* pRequest) = CHttpIo::HTTPIoTypeToStr(m_RequestMethod) + ' ';
    CString HostString = m_Url.GetHost();
    int DefaultPortValue = 80; 
    if (m_Url.GetScheme().Same(g_strProto_HTTPS)) DefaultPortValue = 443;
    if (m_Url.GetPortValue() != DefaultPortValue) {
      HostString.Append(':');
      HostString.Append(m_Url.GetPort());
    }
    if (m_Proxy.GetValid() || (HttpVersion < 1)) {      
      pRequest->Append(m_Url.GetScheme());
      pRequest->Append(g_strColSlashSlash);
      pRequest->Append(HostString);
    }
    CString UrlPath = m_Url.GetUrlPath();
    CHtmlParser::TranslateQuotes(UrlPath);
    pRequest->Append(CUrl::Escape(UrlPath, false));
    if (HttpVersion >= 1.0) {
      pRequest->Append(g_strHttpSpaceOneZero);
      CStringTable Table;
      Table.Set(g_strName, g_strHttpHost);
      Table.Set(g_strValue, HostString);
      m_HttpFields.Set(g_strHttpHost, Table);
    } else m_HttpFields.Remove(g_strHttpHost);
    pRequest->Append(g_strCrLf);
    for (register int i=0;i<(int) m_HttpFields.GetSize();i++) {
      pRequest->Append(m_HttpFields.GetKeyAt(i));
      pRequest->Append(g_strColSpace);
      pRequest->Append(m_HttpFields[i].GetValue(g_strValue));
      for (register int j=0;j<(int)m_HttpFields[i].GetSize();j++) {
        if ((!m_HttpFields[i].GetNameAt(j).Same(g_strName)) &&
            (!m_HttpFields[i].GetNameAt(j).Same(g_strValue))) {
          pRequest->Append(g_strSemiColSpace);
          pRequest->Append(m_HttpFields[i].GetNameAt(j));
          pRequest->Append('=');
          pRequest->Append(m_HttpFields[i].GetValueAt(j));
        }
      }
      pRequest->Append(g_strCrLf);
    }    
    pRequest->Append(g_strCrLf);
}
Ejemplo n.º 3
0
void CHttpRequest::SetPostField(const CString& Group, const CString& Name, const CString& Value) {
    CStringTable Table = m_PostFields.FindElement(Group);
    Table.Set(Name, Value);
    m_PostFields.Set(Group, Table);
}