[Progress Communities] [Progress OpenEdge ABL] Forum Post: PASOE / WebHandlers ... more than one cookie supported?

  • Thread starter Thread starter brianlafertewk
  • Start date Start date
Status
Not open for further replies.
B

brianlafertewk

Guest
I'm working in OpenEdge 11.7.2 (on Windows) and attempting to set and get cookies using PASOE WebHandlers via REST requests (using Postman). I put together two simple handlers maps (/MyApp/web/SetCookies and /MyApp/web/GetCookies) that respond to GET requests. 'SetCookies' sets up three cookies (Cookie1, Cookie2, and Cookie3). Using Postman I set the three cookies get set appropriately in the domain and path expected. When sending a request to 'GetCookies' I am expecting to get back a JSON object with three entries (Cookie1, Cookie2, Cookie3). Using Postman I can see that I am passing in all three cookies. The response I get back is the first cookie only (Cookie1). If in Postman I delete Cookie1, the response I get back will be the new first cookie (Cookie2). For a minute I thought I could be building the response incorrectly, so I added a message statement in the logic that gets the cookies and spins through them, and only one cookie will appear in the array, no matter how many I have set. I've tried setting the cookies simply (as the code below) and with the different security settings, all with the same result ... only the first cookie appears. I'm seeing the same result whether I attempt this directly to the PASOE instance or using BonCode AJP13 protocol from IIS to PASOE. Is this a bug, or am I missing something simple? Code sample follows. Thanks, Brian METHOD OVERRIDE PROTECTED INTEGER HandleGet( INPUT poRequest AS OpenEdge.Web.IWebRequest ): DEFINE VARIABLE oResponse AS OpenEdge.Net.HTTP.IHttpResponse NO-UNDO. DEFINE VARIABLE oWriter AS OpenEdge.Web.WebResponseWriter NO-UNDO. DEFINE VARIABLE oBody AS OpenEdge.Core.String NO-UNDO. DEFINE VARIABLE oCookies AS OpenEdge.Net.HTTP.Cookie EXTENT NO-UNDO. DEFINE VARIABLE oData AS Progress.Json.ObjectModel.JSONObject NO-UNDO. DEFINE VARIABLE x AS INTEGER NO-UNDO. CASE poRequest:UriTemplate: WHEN "/SetCookies" THEN DO: ASSIGN oResponse = NEW OpenEdge.Web.WebResponse() oResponse:StatusCode = INTEGER(StatusCodeEnum:OK) oBody = NEW OpenEdge.Core.String('[~{"msg":"cookies set"~}]') oResponse:Entity = oBody oResponse:ContentType = 'application/json':u oResponse:ContentLength = oBody:Size . oResponse:SetCookie(NEW OpenEdge.Net.HTTP.Cookie("Cookie1",'.','/',STRING(RANDOM(1,100000)))). oResponse:SetCookie(NEW OpenEdge.Net.HTTP.Cookie("Cookie2",'.','/',STRING(RANDOM(1,100000)))). oResponse:SetCookie(NEW OpenEdge.Net.HTTP.Cookie("Cookie3",'.','/',STRING(RANDOM(1,100000)))). END. WHEN "/GetCookies" THEN DO: poRequest:GetCookies(oCookies). oData = NEW Progress.Json.ObjectModel.JSONObject(). DO x = 1 TO EXTENT(oCookies): oData:Add(oCookies[x]:Name, oCookies[x]:Value). END. ASSIGN oResponse = NEW OpenEdge.Web.WebResponse() oResponse:StatusCode = INTEGER(StatusCodeEnum:OK) oResponse:Entity = oData oResponse:ContentType = 'application/json':u oResponse:ContentLength = LENGTH(oData:GetJsonText()) . END. OTHERWISE DO: RETURN HandleNotImplemented(poRequest). END. END CASE. ASSIGN oWriter = NEW WebResponseWriter(oResponse). oWriter:Open(). oWriter:Close(). RETURN 0. END METHOD.

Continue reading...
 
Status
Not open for further replies.
Back
Top