Skip to content

Commit

Permalink
Fixes #39
Browse files Browse the repository at this point in the history
  • Loading branch information
milani committed May 25, 2012
1 parent 35d2606 commit 0912c5e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
5 changes: 2 additions & 3 deletions lib/router/static_router.js
Expand Up @@ -31,8 +31,7 @@ function staticRouter(rootDir){
}

mime_type = mime.lookup(filePath);

res.send(200,mime_type,content.toString());
res.send(200,mime_type,content);

})

Expand All @@ -46,4 +45,4 @@ function staticRouter(rootDir){

}

module.exports = staticRouter;
module.exports = staticRouter;
20 changes: 11 additions & 9 deletions src/includes/cef_scheme_handler.cpp
@@ -1,4 +1,5 @@
#include <node.h>
#include <node_buffer.h>
#include "includes/cef_scheme_handler.h"
#include "includes/cef_handler.h"
#include "includes/util.h"
Expand Down Expand Up @@ -106,14 +107,17 @@ void AppjsSchemeHandler::Execute(CefThreadId threadId) {

Handle<Value> AppjsSchemeHandler::NodeCallback(const Arguments& args) {

HandleScope scope;

AppjsSchemeHandler* me = static_cast<AppjsSchemeHandler *>(UnwrapObject(args.Data()));

AutoLock lock_scope(me);

me->status_ = args[0]->NumberValue();
me->status_text_ = appjs::V8StringToChar(args[1]->ToString());
me->mime_type_ = appjs::V8StringToChar(args[2]->ToString());
me->data_ = appjs::V8StringToChar(args[3]->ToString());
me->data_ = node::Buffer::Data(args[3]->ToObject());
me->data_length_ = node::Buffer::Length(args[3]->ToObject());

me->callback_->HeadersAvailable();

Expand All @@ -131,7 +135,8 @@ bool AppjsSchemeHandler::ProcessRequest(CefRefPtr<CefRequest> request,
status_ = 404;
status_text_ = "Not Found";
mime_type_ = "";
data_ = "";
data_ = NULL;
data_length_ = 0;
offset_ = 0;
request_ = request;
callback_ = callback;
Expand All @@ -147,14 +152,12 @@ void AppjsSchemeHandler::GetResponseHeaders(CefRefPtr<CefResponse> response,
{
REQUIRE_IO_THREAD();

ASSERT(!data_.empty());

response->SetStatus(status_);
response->SetStatusText(status_text_);
response->SetMimeType(mime_type_);

// Set the resulting response length
response_length = data_.length();
response_length = data_length_;
}

void AppjsSchemeHandler::Cancel() {
Expand All @@ -174,11 +177,10 @@ bool AppjsSchemeHandler::ReadResponse(void* data_out,

AutoLock lock_scope(this);

if (offset_ < data_.length()) {
if (offset_ < data_length_) {
// Copy the next block of data into the buffer.
int transfer_size =
std::min(bytes_to_read, static_cast<int>(data_.length() - offset_));
memcpy(data_out, data_.c_str() + offset_, transfer_size);
int transfer_size = std::min(bytes_to_read, static_cast<int>(data_length_ - offset_));
memcpy(data_out, data_ + offset_, transfer_size);
offset_ += transfer_size;

bytes_read = transfer_size;
Expand Down
3 changes: 2 additions & 1 deletion src/includes/cef_scheme_handler.h
Expand Up @@ -35,8 +35,9 @@ class AppjsSchemeHandler
CefRefPtr<CefRequest> request_;
CefRefPtr<CefSchemeHandlerCallback> callback_;
std::string status_text_;
std::string data_;
std::string mime_type_;
char* data_;
int data_length_;
size_t offset_;
int status_;

Expand Down

0 comments on commit 0912c5e

Please sign in to comment.