Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Soheil Armin
QAADockerBuild
Commits
3888dc6d
Commit
3888dc6d
authored
Mar 17, 2022
by
Soheil Armin
Browse files
added chunked data for keep-alive http replies
parent
ac508832
Changes
2
Hide whitespace changes
Inline
Side-by-side
qhttprequest.cpp
View file @
3888dc6d
...
...
@@ -40,6 +40,7 @@ void QHttpRequest::start()
m_requestBody
);
connect
(
reply
,
&
QNetworkReply
::
finished
,
this
,
&
QHttpRequest
::
processReply
);
connect
(
reply
,
&
QNetworkReply
::
readyRead
,
this
,
&
QHttpRequest
::
processChunk
);
}
void
QHttpRequest
::
processReply
()
...
...
@@ -49,7 +50,8 @@ void QHttpRequest::processReply()
if
(
reply
==
nullptr
)
return
;
if
(
reply
->
error
()
==
QNetworkReply
::
NoError
)
if
(
reply
->
error
()
==
QNetworkReply
::
NoError
&&
reply
->
header
(
QNetworkRequest
::
ContentLengthHeader
).
isValid
())
createResponse
(
reply
);
auto
httpStatusCode
=
reply
->
attribute
(
QNetworkRequest
::
HttpStatusCodeAttribute
).
toInt
();
...
...
@@ -69,6 +71,17 @@ void QHttpRequest::processReply()
emit
finished
();
}
void
QHttpRequest
::
processChunk
()
{
auto
reply
=
qobject_cast
<
QNetworkReply
*>
(
sender
());
if
(
reply
==
nullptr
)
return
;
if
(
!
reply
->
header
(
QNetworkRequest
::
ContentLengthHeader
).
isValid
())
{
emit
dataChunk
(
reply
->
readAll
());
}
}
QJSValue
QHttpRequest
::
getResponseBody
()
const
{
return
m_responseBody
;
...
...
qhttprequest.h
View file @
3888dc6d
...
...
@@ -30,6 +30,7 @@ public:
public
Q_SLOTS
:
void
start
();
void
processReply
();
void
processChunk
();
private:
...
...
@@ -62,6 +63,7 @@ signals:
void
headersChanged
(
const
QVariantMap
&
headers
);
void
parametersChanged
(
const
QVariantMap
&
parameters
);
void
requestBodyChanged
(
const
QByteArray
&
requestBody
);
void
dataChunk
(
const
QByteArray
&
data
);
void
responseBodyChanged
(
const
QJSValue
&
responseBody
);
void
networkErrorChanged
(
int
networkError
);
...
...
@@ -70,8 +72,6 @@ signals:
void
runningChanged
(
bool
running
);
void
finished
();
void
error
();
};
static
void
registerQHttpRequest
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment