Skip to content

Commit

Permalink
Set the correct size for resources in random browsing mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tey committed Mar 16, 2015
1 parent dfa6a95 commit 459b07d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/applications/httptools/HttpServerBase.cc
Expand Up @@ -359,6 +359,16 @@ HttpReplyMessage* HttpServerBase::generateResourceMessage(HttpRequestMessage *re
else if (category==CT_IMAGE)
imgResourcesServed++;

int size;
if (scriptedMode)
size = resources[resource];
else if (category==CT_TEXT)
size = (int) rdTextResourceSize->draw();
else if (category==CT_IMAGE)
size = (int) rdImageResourceSize->draw();
else
error("Invalid resource category");

char szReply[512];
sprintf(szReply, "HTTP/1.1 200 OK (%s)", resource.c_str());
HttpReplyMessage* replymsg = new HttpReplyMessage(szReply);
Expand All @@ -369,7 +379,7 @@ HttpReplyMessage* HttpServerBase::generateResourceMessage(HttpRequestMessage *re
replymsg->setSerial(request->serial());
replymsg->setResult(200);
replymsg->setContentType(category); // Emulates the content-type header field
replymsg->setByteLength(resources[resource]); // Set the resource size
replymsg->setByteLength(size); // Set the resource size
replymsg->setKind(HTTPT_RESPONSE_MESSAGE);

sprintf(szReply, "RESOURCE-BODY:%s", resource.c_str());
Expand Down

0 comments on commit 459b07d

Please sign in to comment.