Permalink
Browse files

http: Refactor ResponseStream and SconesiteStream, support JSON uploads

  • Loading branch information...
sconemad committed Oct 10, 2017
1 parent b2b72a9 commit b4402a37715e09dcb40c5ea694c30c8288669e11
Showing with 319 additions and 203 deletions.
  1. +2 −1 config.h.in
  2. +19 −1 http/Request.cpp
  3. +7 −1 http/Request.h
  4. +202 −72 http/ResponseStream.cpp
  5. +41 −22 http/ResponseStream.h
  6. +3 −1 sconesite/Makefile.am
  7. +40 −104 sconesite/SconesiteStream.cpp
  8. +5 −1 sconesite/SconesiteStream.h
@@ -260,7 +260,8 @@
slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK

/* Define to the sub-directory where libtool stores uninstalled libraries. */
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR

/* Name of package */
@@ -33,7 +33,8 @@ Request::Request(const std::string& id)
: m_host(0),
m_id(id),
m_session(0),
m_params(new scx::ScriptMap())
m_params(new scx::ScriptMap()),
m_body(0)
{

}
@@ -42,6 +43,7 @@ Request::Request(const std::string& id)
Request::~Request()
{
delete m_session;
delete m_body;
}

//===========================================================================
@@ -310,6 +312,20 @@ std::string Request::build_header_string()
return str;
}


//=========================================================================
void Request::set_body(scx::ScriptRef* body)
{
delete m_body;
m_body = body;
}

//=========================================================================
scx::ScriptRef* Request::get_body()
{
return m_body;
}

//=========================================================================
std::string Request::get_string() const
{
@@ -341,6 +357,8 @@ scx::ScriptRef* Request::script_op(const scx::ScriptAuth& auth,
return m_params.ref_copy(ref.reftype());
if (name == "session" && m_session)
return m_session->ref_copy(ref.reftype());
if (name == "body" && m_body)
return m_body->ref_copy(ref.reftype());
}

return scx::ScriptObject::script_op(auth,ref,op,right);
@@ -81,9 +81,12 @@ class HTTP_API Request : public scx::ScriptObject {
void set_param(const std::string& name, const std::string& value);
std::string get_param(const std::string& name) const;
bool is_param(const std::string& name) const;

std::string build_header_string();

void set_body(scx::ScriptRef* body);
scx::ScriptRef* get_body();

// ScriptObject methods
virtual std::string get_string() const;

@@ -147,6 +150,9 @@ class HTTP_API Request : public scx::ScriptObject {

// Parameters sent with the request
scx::ScriptMap::Ref m_params;

// Request body
scx::ScriptRef* m_body;

};

Oops, something went wrong.

0 comments on commit b4402a3

Please sign in to comment.