Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
ofbiz-directcontrolservlet
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
a80bfaac
authored
2016-11-28 15:20:00 -0600
by
Ean Schuessler
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add support for cookies and headers
Refs: #8039
1 parent
33225dc9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
src/com/brainfood/ofbiz/DirectControlServlet.java
src/com/brainfood/ofbiz/DirectControlServlet.java
View file @
a80bfaa
...
...
@@ -439,6 +439,14 @@ public class DirectControlServlet extends HttpServlet {
context
.
put
(
"httpProtocol"
,
request
.
getProtocol
());
context
.
put
(
"httpScheme"
,
request
.
getScheme
());
Enumeration
headerNames
=
request
.
getHeaderNames
();
Map
<
String
,
List
>
headerMap
=
new
HashMap
<
String
,
List
>();
while
(
headerNames
.
hasMoreElements
())
{
String
headerName
=
(
String
)
headerNames
.
nextElement
();
headerMap
.
put
(
headerName
,
Collections
.
list
(
request
.
getHeaders
(
headerName
)));
}
context
.
put
(
"httpHeaders"
,
headerMap
);
DispatchContext
dctx
=
dispatcher
.
getDispatchContext
();
ModelService
model
=
dctx
.
getModelService
(
serviceName
);
...
...
@@ -452,6 +460,22 @@ public class DirectControlServlet extends HttpServlet {
Map
<
String
,
Object
>
result
=
dispatcher
.
runSync
(
serviceName
,
context
);
if
(
result
.
get
(
"httpHeaders"
)
!=
null
)
{
Map
<
String
,
List
<
String
>>
headers
=
(
Map
<
String
,
List
<
String
>>)
result
.
get
(
"httpHeaders"
);
for
(
String
headerName
:
(
Set
<
String
>)
headers
.
keySet
())
{
for
(
String
value
:
headers
.
get
(
headerName
))
{
response
.
addHeader
(
headerName
,
value
);
}
}
}
if
(
result
.
get
(
"httpCookies"
)
!=
null
)
{
List
<
Cookie
>
cookies
=
(
List
<
Cookie
>)
result
.
get
(
"httpCookies"
);
for
(
Cookie
cookie
:
cookies
)
{
response
.
addCookie
(
cookie
);
}
}
result
.
remove
(
"responseMessage"
);
Integer
httpStatusCode
=
(
Integer
)
result
.
remove
(
"httpStatusCode"
);
int
statusCode
=
httpStatusCode
==
null
?
200
:
httpStatusCode
.
intValue
();
...
...
Please
register
or
sign in
to post a comment