Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. write.cxx
  5. Abstract:
  6. This file contains the implementation of the HttpWriteData API.
  7. Contents:
  8. HttpWriteData
  9. HTTP_REQUEST_HANDLE_OBJECT::WriteData
  10. Author:
  11. Arthur Bierer (arthurbi) 07-Apr-1997
  12. Revision History:
  13. --*/
  14. #include <wininetp.h>
  15. #include "httpp.h"
  16. //
  17. // functions
  18. //
  19. DWORD
  20. CFsm_HttpWriteData::RunSM(
  21. IN CFsm * Fsm
  22. )
  23. {
  24. DEBUG_ENTER((DBG_HTTP,
  25. Dword,
  26. "CFsm_HttpWriteData::RunSM",
  27. "%#x",
  28. Fsm
  29. ));
  30. DWORD error;
  31. HTTP_REQUEST_HANDLE_OBJECT * pRequest;
  32. CFsm_HttpWriteData * stateMachine = (CFsm_HttpWriteData *)Fsm;
  33. pRequest = (HTTP_REQUEST_HANDLE_OBJECT *)Fsm->GetContext();
  34. switch (Fsm->GetState()) {
  35. case FSM_STATE_INIT:
  36. //
  37. // Fall through
  38. //
  39. case FSM_STATE_CONTINUE:
  40. error = pRequest->HttpWriteData_Fsm(stateMachine);
  41. break;
  42. case FSM_STATE_ERROR:
  43. error = Fsm->GetError();
  44. INET_ASSERT (error == ERROR_WINHTTP_OPERATION_CANCELLED);
  45. Fsm->SetDone();
  46. break;
  47. default:
  48. error = ERROR_WINHTTP_INTERNAL_ERROR;
  49. Fsm->SetDone(ERROR_WINHTTP_INTERNAL_ERROR);
  50. INET_ASSERT(FALSE);
  51. break;
  52. }
  53. DEBUG_LEAVE(error);
  54. return error;
  55. }
  56. DWORD
  57. HTTP_REQUEST_HANDLE_OBJECT::HttpWriteData_Fsm(
  58. IN CFsm_HttpWriteData * Fsm
  59. )
  60. {
  61. DEBUG_ENTER((DBG_HTTP,
  62. Dword,
  63. "HTTP_REQUEST_HANDLE_OBJECT::HttpWriteData_Fsm",
  64. "%#x",
  65. Fsm
  66. ));
  67. CFsm_HttpWriteData & fsm = *Fsm;
  68. DWORD error = fsm.GetError();
  69. if (fsm.GetState() == FSM_STATE_INIT) {
  70. if (!IsValidHttpState(WRITE)) {
  71. error = ERROR_WINHTTP_INCORRECT_HANDLE_STATE;
  72. goto quit;
  73. }
  74. error = _Socket->Send(
  75. fsm.m_lpBuffer,
  76. fsm.m_dwNumberOfBytesToWrite,
  77. SF_INDICATE
  78. );
  79. }
  80. if (error == ERROR_SUCCESS)
  81. {
  82. *fsm.m_lpdwNumberOfBytesWritten = fsm.m_dwNumberOfBytesToWrite;
  83. SetBytesWritten(fsm.m_dwNumberOfBytesToWrite);
  84. }
  85. quit:
  86. if (error != ERROR_IO_PENDING) {
  87. fsm.SetDone();
  88. }
  89. DEBUG_LEAVE(error);
  90. return error;
  91. }