Fixed proxying chunks problems.
This commit is contained in:
parent
f21ce291ae
commit
5b38492c8b
1 changed files with 7 additions and 7 deletions
|
@ -124,20 +124,20 @@ void HTTP::Parser::SendResponse(std::string code, std::string message, Socket::C
|
||||||
void HTTP::Parser::Proxy(Socket::Connection & from, Socket::Connection & to){
|
void HTTP::Parser::Proxy(Socket::Connection & from, Socket::Connection & to){
|
||||||
SendResponse("200", "OK", to);
|
SendResponse("200", "OK", to);
|
||||||
if (getChunks){
|
if (getChunks){
|
||||||
int doingChunk = 0;
|
int proxyingChunk = 0;
|
||||||
while (to.connected() && from.connected()){
|
while (to.connected() && from.connected()){
|
||||||
if (from.Received().size() || from.spool()){
|
if ((from.Received().size() && (from.Received().size() > 2 || *(from.Received().get().rbegin()) == '\n')) || from.spool()){
|
||||||
if (doingChunk){
|
if (proxyingChunk){
|
||||||
unsigned int toappend = from.Received().get().size();
|
unsigned int toappend = from.Received().get().size();
|
||||||
if (toappend > doingChunk){
|
if (toappend > proxyingChunk){
|
||||||
toappend = doingChunk;
|
toappend = proxyingChunk;
|
||||||
to.SendNow(from.Received().get().c_str(), toappend);
|
to.SendNow(from.Received().get().c_str(), toappend);
|
||||||
from.Received().get().erase(0, toappend);
|
from.Received().get().erase(0, toappend);
|
||||||
}else{
|
}else{
|
||||||
to.SendNow(from.Received().get());
|
to.SendNow(from.Received().get());
|
||||||
from.Received().get().clear();
|
from.Received().get().clear();
|
||||||
}
|
}
|
||||||
doingChunk -= toappend;
|
proxyingChunk -= toappend;
|
||||||
}else{
|
}else{
|
||||||
//Make sure the received data ends in a newline (\n).
|
//Make sure the received data ends in a newline (\n).
|
||||||
if ( *(from.Received().get().rbegin()) != '\n'){
|
if ( *(from.Received().get().rbegin()) != '\n'){
|
||||||
|
@ -167,7 +167,7 @@ void HTTP::Parser::Proxy(Socket::Connection & from, Socket::Connection & to){
|
||||||
to.SendNow("\r\n", 2);
|
to.SendNow("\r\n", 2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
doingChunk = chunkLen;
|
proxyingChunk = chunkLen;
|
||||||
}
|
}
|
||||||
from.Received().get().clear();
|
from.Received().get().clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue