Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/ofxHttpUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ ofxHttpUtils::ofxHttpUtils(){

// ----------------------------------------------------------------------
ofxHttpUtils::~ofxHttpUtils(){
stop();
waitForThread(false);
}

// ----------------------------------------------------------------------
Expand Down Expand Up @@ -155,6 +157,7 @@ string ofxHttpUtils::generateUrl(ofxHttpForm & form) {
// ----------------------------------------------------------------------
ofxHttpResponse ofxHttpUtils::postData(string url, const ofBuffer & data, string contentType){
ofxHttpResponse response;

try{
URI uri( url.c_str() );
std::string path(uri.getPathAndQuery());
Expand Down Expand Up @@ -206,7 +209,8 @@ ofxHttpResponse ofxHttpUtils::postData(string url, const ofBuffer & data, strin
uri.resolve(res.get("Location"));
response.location = uri.toString();
}


response.buffer= data;
ofNotifyEvent(newResponseEvent, response, this);
}catch (Exception& exc){

Expand All @@ -218,9 +222,12 @@ ofxHttpResponse ofxHttpUtils::postData(string url, const ofBuffer & data, strin
ofLogError("ofxHttpUtils") << exc.displayText();
response.status = -1;
response.reasonForStatus = exc.displayText();

response.buffer= data;
ofNotifyEvent(newResponseEvent, response, this);

}

return response;
}

Expand Down Expand Up @@ -306,6 +313,7 @@ ofxHttpResponse ofxHttpUtils::doPostForm(ofxHttpForm & form){
response.location = uri.toString();
}

response.form= form;
ofNotifyEvent(newResponseEvent, response, this);


Expand All @@ -318,10 +326,12 @@ ofxHttpResponse ofxHttpUtils::doPostForm(ofxHttpForm & form){
ofLogError("ofxHttpUtils") << exc.displayText();
response.status = -1;
response.reasonForStatus = exc.displayText();

response.form= form;
ofNotifyEvent(newResponseEvent, response, this);

}

return response;
}

Expand Down
3 changes: 3 additions & 0 deletions src/ofxHttpUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ struct ofxHttpResponse{
std::string url;
std::vector<Poco::Net::HTTPCookie> cookies;
std::string location;

ofxHttpForm form;
ofBuffer buffer;
};

class ofxHttpUtils : public ofThread{
Expand Down