You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As we can see in src/core/aws-server-http_utils.adb:1587
File_Mode : constant Boolean :=
Response.Mode (Answer) in
Response.File .. Response.Stream;
With_Body : constant Boolean := Messages.With_Body (Status_Code);
File_Time : Ada.Calendar.Time;
F_Status : constant Resource_Status :=
Get_Resource_Status (C_Stat, Filename, File_Time);
File : Resources.File_Type;
begin
if F_Status in Up_To_Date .. Not_Found then
if F_Status = Up_To_Date then
-- [RFC 2616 - 10.3.5]
Status_Code := Messages.S304;
else
-- File is not found on disk, returns now with 404
Status_Code := Messages.S404;
end if;
Set_General_Header (Status_Code);
Headers.Send_Header
(Socket => Sock, Headers => H_List, End_Block => True);
return;
File resource status is managed in all cases, even when Response.Mode (Answer) = Response.Message. This can happen in the following context;
Server A web service creates an answer using AWS.Response.File
Server B web service calls server A web service above using AWS.Client.Get and send back the response to the client
The patch below fix this issue by managing the file resource status only when the answer File_Mode is True, that is when Response.Mode (Answer) in Response.File .. Response.Stream. However shall we instead manage the file resource status for the File and File_Once modes only, keeping Stream mode out of it ?
File_Mode : constant Boolean :=
Response.Mode (Answer) in
Response.File .. Response.Stream;
With_Body : constant Boolean := Messages.With_Body (Status_Code);
File_Time : Ada.Calendar.Time;
F_Status : constant Resource_Status :=
(case File_Mode is
when False => Changed,
when True => Get_Resource_Status (C_Stat, Filename, File_Time)
);
File : Resources.File_Type;
begin
if File_Mode and then F_Status in Up_To_Date .. Not_Found then
if F_Status = Up_To_Date then
@dsauvage : It seems that this is already the case. If Filename = "" then Get_Resource_Status returns Changed, so I'm not sure this adds something. Right?
No, it is not already the case. If on server A, AWS.Response.File is called with Disposition => AWS.Response.Attachment, then when server B will send the data, it will have File_Mode set to Message, and Filename set to non empty, thus leading to an HTTP 404 error status, as the Mode is Message and server B is erroneously checking for the existence of a file that does not exist on server B.
The proposed patch solve this bug.
Description
As we can see in
src/core/aws-server-http_utils.adb:1587
File resource status is managed in all cases, even when
Response.Mode (Answer) = Response.Message
. This can happen in the following context;Server A web service creates an answer using
AWS.Response.File
Server B web service calls server A web service above using
AWS.Client.Get
and send back the response to the clientThe patch below fix this issue by managing the file resource status only when the answer
File_Mode
isTrue
, that is whenResponse.Mode (Answer) in Response.File .. Response.Stream
. However shall we instead manage the file resource status for theFile
andFile_Once
modes only, keepingStream
mode out of it ?Patch
aws-server-http_utils.adb.patch.txt
The text was updated successfully, but these errors were encountered: