HttpClient.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright: JessMA Open Source (ldcsaa@gmail.com)
  3. *
  4. * Version : 3.6.1
  5. * Author : Bruce Liang
  6. * Website : http://www.jessma.org
  7. * Project : https://github.com/ldcsaa
  8. * Blog : http://www.cnblogs.com/ldcsaa
  9. * Wiki : http://www.oschina.net/p/hp-socket
  10. * QQ Group : 75375912
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the "License");
  13. * you may not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * http://www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an "AS IS" BASIS,
  20. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. #include "stdafx.h"
  25. #include "HttpClient.h"
  26. template<class T> BOOL CHttpClientT<T>::CheckParams()
  27. {
  28. if (m_enLocalVersion != HV_1_1 && m_enLocalVersion != HV_1_0)
  29. {
  30. SetLastError(SE_INVALID_PARAM, __FUNCTION__, ERROR_INVALID_PARAMETER);
  31. return FALSE;
  32. }
  33. return __super::CheckParams();
  34. }
  35. template<class T> BOOL CHttpClientT<T>::SendRequest(LPCSTR lpszMethod, LPCSTR lpszPath, const THeader lpHeaders[], int iHeaderCount, const BYTE* pBody, int iLength)
  36. {
  37. WSABUF szBuffer[2];
  38. CStringA strHeader;
  39. ::MakeRequestLine(lpszMethod, lpszPath, m_enLocalVersion, strHeader);
  40. ::MakeHeaderLines(lpHeaders, iHeaderCount, &m_objHttp.GetCookieMap(), iLength, TRUE, strHeader);
  41. ::MakeHttpPacket(strHeader, pBody, iLength, szBuffer);
  42. return SendPackets(szBuffer, 2);
  43. }
  44. template class CHttpClientT<CTcpClient>;
  45. #ifdef _SSL_SUPPORT
  46. #include "SSLClient.h"
  47. template class CHttpClientT<CSSLClient>;
  48. #endif