\r
case HTTP_STATUS_307_TEMPORARY_REDIRECT:\r
AsciiPrint ("\n Redirection: 307 Temporary Redirect");\r
+ break;\r
+\r
+ case HTTP_STATUS_308_PERMANENT_REDIRECT:\r
+ AsciiPrint ("\n Redirection: 308 Permanent Redirect");\r
break; \r
\r
case HTTP_STATUS_400_BAD_REQUEST:\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Notify the callback function when an event is triggered.\r
+\r
+ @param[in] Context The opaque parameter to the function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HttpIoNotifyDpc (\r
+ IN VOID *Context\r
+ )\r
+{\r
+ *((BOOLEAN *) Context) = TRUE;\r
+}\r
+\r
+/**\r
+ Request HttpIoNotifyDpc as a DPC at TPL_CALLBACK.\r
+\r
+ @param[in] Event The event signaled.\r
+ @param[in] Context The opaque parameter to the function.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HttpIoNotify (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ //\r
+ // Request HttpIoNotifyDpc as a DPC at TPL_CALLBACK\r
+ //\r
+ QueueDpc (TPL_CALLBACK, HttpIoNotifyDpc, Context);\r
+}\r
+\r
/**\r
Create a HTTP_IO to access the HTTP service. It will create and configure\r
a HTTP child handle.\r
@param[in] Controller The handle of the controller.\r
@param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r
@param[in] ConfigData The HTTP_IO configuration data.\r
+ @param[in] Callback Callback function which will be invoked when specified\r
+ HTTP_IO_CALLBACK_EVENT happened.\r
+ @param[in] Context The Context data which will be passed to the Callback function.\r
@param[out] HttpIo The HTTP_IO.\r
\r
@retval EFI_SUCCESS The HTTP_IO is created and configured.\r
IN EFI_HANDLE Controller,\r
IN UINT8 IpVersion,\r
IN HTTP_IO_CONFIG_DATA *ConfigData,\r
+ IN HTTP_IO_CALLBACK Callback,\r
+ IN VOID *Context,\r
OUT HTTP_IO *HttpIo\r
)\r
{\r
HttpIo->Controller = Controller;\r
HttpIo->IpVersion = IpVersion;\r
HttpIo->Http = Http;\r
+ HttpIo->Callback = Callback;\r
+ HttpIo->Context = Context;\r
\r
ZeroMem (&HttpConfigData, sizeof (EFI_HTTP_CONFIG_DATA));\r
HttpConfigData.HttpVersion = HttpVersion11;\r
Status = gBS->CreateEvent (\r
EVT_NOTIFY_SIGNAL,\r
TPL_NOTIFY,\r
- HttpBootCommonNotify,\r
+ HttpIoNotify,\r
&HttpIo->IsTxDone,\r
&Event\r
);\r
Status = gBS->CreateEvent (\r
EVT_NOTIFY_SIGNAL,\r
TPL_NOTIFY,\r
- HttpBootCommonNotify,\r
+ HttpIoNotify,\r
&HttpIo->IsRxDone,\r
&Event\r
);\r
HttpIo->ReqToken.Message->BodyLength = BodyLength;\r
HttpIo->ReqToken.Message->Body = Body;\r
\r
+ if (HttpIo->Callback != NULL) {\r
+ Status = HttpIo->Callback (\r
+ HttpIoRequest,\r
+ HttpIo->ReqToken.Message,\r
+ HttpIo->Context\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ }\r
+\r
//\r
// Queue the request token to HTTP instances.\r
//\r
HttpIo->IsRxDone = FALSE;\r
}\r
\r
+ if (!EFI_ERROR (HttpIo->RspToken.Status) && HttpIo->Callback != NULL) {\r
+ Status = HttpIo->Callback (\r
+ HttpIoResponse,\r
+ HttpIo->RspToken.Message,\r
+ HttpIo->Context\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ }\r
+\r
//\r
// Store the received data into the wrapper.\r
//\r
\r
//\r
// Determine the image type by the HTTP Content-Type header field first.\r
- // "application/efi" -> EFI Image\r
+ // "application/efi" -> EFI Image\r
+ // "application/vnd.efi-iso" -> CD/DVD Image\r
+ // "application/vnd.efi-img" -> Virtual Disk Image\r
//\r
Header = HttpFindHeader (HeaderCount, Headers, HTTP_HEADER_CONTENT_TYPE);\r
if (Header != NULL) {\r
if (AsciiStriCmp (Header->FieldValue, HTTP_CONTENT_TYPE_APP_EFI) == 0) {\r
*ImageType = ImageTypeEfi;\r
return EFI_SUCCESS;\r
+ } else if (AsciiStriCmp (Header->FieldValue, HTTP_CONTENT_TYPE_APP_ISO) == 0) {\r
+ *ImageType = ImageTypeVirtualCd;\r
+ return EFI_SUCCESS;\r
+ } else if (AsciiStriCmp (Header->FieldValue, HTTP_CONTENT_TYPE_APP_IMG) == 0) {\r
+ *ImageType = ImageTypeVirtualDisk;\r
+ return EFI_SUCCESS;\r
}\r
}\r
\r