[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp libbas...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp libbas... |
Date: |
Thu, 22 Feb 2007 08:53:37 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/02/22 08:53:37
Modified files:
. : ChangeLog
libbase : curl_adapter.cpp curl_adapter.h
Log message:
* libbase/curl_adapter.{cpp,h}:
Add support for http POST (untested).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2428&r2=1.2429
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/curl_adapter.cpp?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/curl_adapter.h?cvsroot=gnash&r1=1.4&r2=1.5
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2428
retrieving revision 1.2429
diff -u -b -r1.2428 -r1.2429
--- ChangeLog 21 Feb 2007 23:43:43 -0000 1.2428
+++ ChangeLog 22 Feb 2007 08:53:37 -0000 1.2429
@@ -1,3 +1,8 @@
+2007-02-22 Sandro Santilli <address@hidden>
+
+ * libbase/curl_adapter.{cpp,h}:
+ Add support for http POST (untested).
+
2007-02-21 Sandro Santilli <address@hidden>
* testsuite/actionscript.all/Makefile.am:
Index: libbase/curl_adapter.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/curl_adapter.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- libbase/curl_adapter.cpp 9 Nov 2006 13:05:39 -0000 1.19
+++ libbase/curl_adapter.cpp 22 Feb 2007 08:53:37 -0000 1.20
@@ -16,7 +16,7 @@
//
-/* $Id: curl_adapter.cpp,v 1.19 2006/11/09 13:05:39 bjacques Exp $ */
+/* $Id: curl_adapter.cpp,v 1.20 2007/02/22 08:53:37 strk Exp $ */
#if defined(_WIN32) || defined(WIN32)
#define snprintf _snprintf
@@ -36,6 +36,9 @@
#include "GnashException.h"
#include "log.h"
+#include <map>
+#include <string>
+
//#define GNASH_CURL_VERBOSE 1
// define this if you want seeks back to be reported (on stderr)
@@ -84,9 +87,21 @@
public:
+ typedef std::map<std::string, std::string> PostData;
+
/// Open a stream from the specified URL
CurlStreamFile(const std::string& url);
+ /// Open a stream from the specified URL posting the specified variables
+ //
+ /// @param url
+ /// The url to post to.
+ ///
+ /// @param vars
+ /// The url-encoded post data.
+ ///
+ CurlStreamFile(const std::string& url, const std::string& vars);
+
~CurlStreamFile();
/// Read 'bytes' bytes into the given buffer.
@@ -106,6 +121,8 @@
private:
+ void init(const std::string& url);
+
// Use this file to cache data
FILE* _cache;
@@ -250,14 +267,15 @@
fprintf(stderr, "_cache.tell = " SIZET_FMT "\n", tell());
}
-/*public*/
-CurlStreamFile::CurlStreamFile(const std::string& url)
- :
- _url(url),
- _running(1)
+/*private*/
+void
+CurlStreamFile::init(const std::string& url)
{
ensure_libcurl_initialized();
+ _url = url;
+ _running = 1;
+
_handle = curl_easy_init();
_mhandle = curl_multi_init();
@@ -270,7 +288,6 @@
_cachefd = fileno(_cache);
CURLcode ccode;
- CURLMcode mcode;
ccode = curl_easy_setopt(_handle, CURLOPT_USERAGENT, "Gnash-" VERSION);
if ( ccode != CURLE_OK ) {
@@ -321,14 +338,46 @@
throw gnash::GnashException(curl_easy_strerror(ccode));
}
+ //fill_cache(32); // pre-cache 32 bytes
+ //curl_multi_perform(_mhandle, &_running);
+}
+
+/*public*/
+CurlStreamFile::CurlStreamFile(const std::string& url)
+{
+ init(url);
+
// CURLMcode ret =
- mcode = curl_multi_add_handle(_mhandle, _handle);
+ CURLMcode mcode = curl_multi_add_handle(_mhandle, _handle);
+ if ( mcode != CURLM_OK ) {
+ throw gnash::GnashException(curl_multi_strerror(mcode));
+ }
+}
+
+/*public*/
+CurlStreamFile::CurlStreamFile(const std::string& url, const std::string& vars)
+{
+ init(url);
+ // TODO: post data !
+
+ CURLcode ccode;
+
+ ccode = curl_easy_setopt(_handle, CURLOPT_POST, 1);
+ if ( ccode != CURLE_OK ) {
+ throw gnash::GnashException(curl_easy_strerror(ccode));
+ }
+
+ ccode = curl_easy_setopt(_handle, CURLOPT_POSTFIELDS, vars.c_str());
+ if ( ccode != CURLE_OK ) {
+ throw gnash::GnashException(curl_easy_strerror(ccode));
+ }
+
+ // CURLMcode ret =
+ CURLMcode mcode = curl_multi_add_handle(_mhandle, _handle);
if ( mcode != CURLM_OK ) {
throw gnash::GnashException(curl_multi_strerror(mcode));
}
- //fill_cache(32); // pre-cache 32 bytes
- //curl_multi_perform(_mhandle, &_running);
}
/*public*/
@@ -472,7 +521,10 @@
return 0;
}
-// this is the only exported interface
+//-------------------------------------------
+// Exported interfaces
+//-------------------------------------------
+
tu_file*
make_stream(const char* url)
{
@@ -503,6 +555,36 @@
close);
}
+tu_file*
+make_stream(const char* url, const std::string& postdata)
+{
+ ensure_libcurl_initialized();
+
+#ifdef GNASH_CURL_VERBOSE
+ fprintf(stderr, "making curl stream for %s\n", url);
+#endif
+
+ CurlStreamFile* stream = NULL;
+
+ try {
+ stream = new CurlStreamFile(url, postdata);
+ } catch (const std::exception& ex) {
+ fprintf(stderr, "curl stream: %s\n", ex.what());
+ delete stream;
+ return NULL;
+ }
+
+ return new tu_file(
+ (void*)stream, // opaque user pointer
+ read, // read
+ write, // write
+ seek, // seek
+ seek_to_end, // seek_to_end
+ tell, // tell
+ eof, // get eof
+ close);
+}
+
} // namespace curl_adapter
#endif // def HAVE_LIBCURL
Index: libbase/curl_adapter.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/curl_adapter.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libbase/curl_adapter.h 29 Oct 2006 18:34:11 -0000 1.4
+++ libbase/curl_adapter.h 22 Feb 2007 08:53:37 -0000 1.5
@@ -17,7 +17,7 @@
//
//
-/* $Id: curl_adapter.h,v 1.4 2006/10/29 18:34:11 rsavoye Exp $ */
+/* $Id: curl_adapter.h,v 1.5 2007/02/22 08:53:37 strk Exp $ */
#ifndef CURL_ADAPTER_H
#define CURL_ADAPTER_H
@@ -42,6 +42,20 @@
///
DSOEXPORT tu_file* make_stream(const char* url);
+/// \brief
+/// Returns a read-only tu_file stream that fetches data
+/// from an url getting posted to.
+//
+/// The caller owns the returned tu_file*.
+///
+/// @param url
+/// The url to post to.
+///
+/// @param postdata
+/// The url-encoded post data
+///
+DSOEXPORT tu_file* make_stream(const char* url, const std::string& postdata);
+
}
#endif // CURL_ADAPTER_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libbase/curl_adapter.cpp libbas...,
Sandro Santilli <=