54 IN VOID *SeedMessage OPTIONAL,
56 IN CHAR8 *DeleteList[] OPTIONAL,
75 SeedHeaderFields =
NULL;
77 TempHeaderFields =
NULL;
79 NewHeaderFields =
NULL;
89 return EFI_INVALID_PARAMETER;
92 if (SeedMessage !=
NULL) {
93 Status = This->Parse (
100 if (EFI_ERROR (Status)) {
108 if ((SeedFieldCount != 0) && (DeleteCount != 0)) {
110 if (TempHeaderFields ==
NULL) {
111 Status = EFI_OUT_OF_RESOURCES;
115 for (Index = 0, TempFieldCount = 0; Index < SeedFieldCount; Index++) {
121 &TempHeaderFields[TempFieldCount],
122 SeedHeaderFields[Index].FieldName,
123 SeedHeaderFields[Index].FieldValue
125 if (EFI_ERROR (Status)) {
133 TempHeaderFields = SeedHeaderFields;
134 TempFieldCount = SeedFieldCount;
141 if (NewHeaderFields ==
NULL) {
142 Status = EFI_OUT_OF_RESOURCES;
146 for (Index = 0; Index < TempFieldCount; Index++) {
148 &NewHeaderFields[Index],
149 TempHeaderFields[Index].FieldName,
150 TempHeaderFields[Index].FieldValue
152 if (EFI_ERROR (Status)) {
157 NewFieldCount = TempFieldCount;
159 for (Index = 0; Index < AppendCount; Index++) {
160 HttpHeader =
HttpFindHeader (NewFieldCount, NewHeaderFields, AppendList[Index]->FieldName);
161 if (HttpHeader !=
NULL) {
164 AppendList[Index]->FieldName,
165 AppendList[Index]->FieldValue
167 if (EFI_ERROR (Status)) {
172 &NewHeaderFields[NewFieldCount],
173 AppendList[Index]->FieldName,
174 AppendList[Index]->FieldValue
176 if (EFI_ERROR (Status)) {
187 for (Index = 0; Index < NewFieldCount; Index++) {
188 HttpHeader = &NewHeaderFields[Index];
191 *NewMessageSize += StrLength;
193 StrLength =
sizeof (
": ") - 1;
194 *NewMessageSize += StrLength;
197 *NewMessageSize += StrLength;
199 StrLength =
sizeof (
"\r\n") - 1;
200 *NewMessageSize += StrLength;
203 StrLength =
sizeof (
"\r\n") - 1;
204 *NewMessageSize += StrLength;
207 if (*NewMessage ==
NULL) {
208 Status = EFI_OUT_OF_RESOURCES;
212 NewMessagePtr = (UINT8 *)(*NewMessage);
214 for (Index = 0; Index < NewFieldCount; Index++) {
215 HttpHeader = &NewHeaderFields[Index];
219 NewMessagePtr += StrLength;
221 StrLength =
sizeof (
": ") - 1;
222 CopyMem (NewMessagePtr,
": ", StrLength);
223 NewMessagePtr += StrLength;
227 NewMessagePtr += StrLength;
229 StrLength =
sizeof (
"\r\n") - 1;
230 CopyMem (NewMessagePtr,
"\r\n", StrLength);
231 NewMessagePtr += StrLength;
234 StrLength =
sizeof (
"\r\n") - 1;
235 CopyMem (NewMessagePtr,
"\r\n", StrLength);
236 NewMessagePtr += StrLength;
238 ASSERT (*NewMessageSize == (
UINTN)NewMessagePtr - (
UINTN)(*NewMessage));
244 if (SeedHeaderFields !=
NULL) {
248 if (TempHeaderFields !=
NULL) {
252 if (NewHeaderFields !=
NULL) {
284 IN CHAR8 *HttpMessage,
291 CHAR8 *TempHttpMessage;
297 UINTN HttpBufferSize;
300 TempHttpMessage =
NULL;
307 if ((This ==
NULL) || (HttpMessage ==
NULL) || (HeaderFields ==
NULL) || (FieldCount ==
NULL)) {
308 return EFI_INVALID_PARAMETER;
314 HttpBufferSize = HttpMessageSize + 1;
316 if (TempHttpMessage ==
NULL) {
317 return EFI_OUT_OF_RESOURCES;
320 CopyMem (TempHttpMessage, HttpMessage, HttpMessageSize);
321 *(TempHttpMessage + HttpMessageSize) =
'\0';
327 Token = TempHttpMessage;
333 if ((FieldName ==
NULL) || (FieldValue ==
NULL)) {
340 if (*FieldCount == 0) {
341 Status = EFI_INVALID_PARAMETER;
349 if (*HeaderFields ==
NULL) {
351 Status = EFI_OUT_OF_RESOURCES;
355 CopyMem (TempHttpMessage, HttpMessage, HttpMessageSize);
360 Token = TempHttpMessage;
361 while (Index < *FieldCount) {
366 if ((FieldName ==
NULL) || (FieldValue ==
NULL)) {
371 if (EFI_ERROR (Status)) {
384 if (TempHttpMessage !=
NULL) {
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI HttpSetFieldNameAndValue(IN OUT EFI_HTTP_HEADER *HttpHeader, IN CONST CHAR8 *FieldName, IN CONST CHAR8 *FieldValue)
EFI_HTTP_HEADER *EFIAPI HttpFindHeader(IN UINTN HeaderCount, IN EFI_HTTP_HEADER *Headers, IN CHAR8 *FieldName)
VOID EFIAPI HttpFreeHeaderFields(IN EFI_HTTP_HEADER *HeaderFields, IN UINTN FieldCount)
CHAR8 *EFIAPI HttpGetFieldNameAndValue(IN CHAR8 *String, OUT CHAR8 **FieldName, OUT CHAR8 **FieldValue)
BOOLEAN EFIAPI HttpIsValidHttpHeader(IN CHAR8 *DeleteList[], IN UINTN DeleteCount, IN CHAR8 *FieldName)
EFI_STATUS EFIAPI HttpUtilitiesParse(IN EFI_HTTP_UTILITIES_PROTOCOL *This, IN CHAR8 *HttpMessage, IN UINTN HttpMessageSize, OUT EFI_HTTP_HEADER **HeaderFields, OUT UINTN *FieldCount)
EFI_STATUS EFIAPI HttpUtilitiesBuild(IN EFI_HTTP_UTILITIES_PROTOCOL *This, IN UINTN SeedMessageSize, IN VOID *SeedMessage OPTIONAL, IN UINTN DeleteCount, IN CHAR8 *DeleteList[] OPTIONAL, IN UINTN AppendCount, IN EFI_HTTP_HEADER *AppendList[] OPTIONAL, OUT UINTN *NewMessageSize, OUT VOID **NewMessage)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)