Skip to content

Commit 81b8672

Browse files
committed
Merge pull request #166 from hildrum/httpFunc
httpPost, httpGet, and httpPut
2 parents 826e61d + 10ea47c commit 81b8672

File tree

16 files changed

+688
-18
lines changed

16 files changed

+688
-18
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ impl/nl/include/*.h
99
/com.ibm.streamsx.inet/impl/nl/InetResource.dat
1010

1111
# generated operator models
12-
/com.ibm.streamsx.inet/com.ibm.streamsx.inet.wsserver/WebSocketInject/WebSocketInject.xml
13-
/com.ibm.streamsx.inet/com.ibm.streamsx.inet.wsserver/WebSocketSend/WebSocketSend.xm
12+
/com.ibm.streamsx.inet/com.ibm.streamsx.inet.wsserver/WebSocketInject/*
13+
/com.ibm.streamsx.inet/com.ibm.streamsx.inet.wsserver/WebSocketSend/*
14+
/com.ibm.streamsx.inet/com.ibm.streamsx.inet.rest/*/*.gif
15+
/com.ibm.streamsx.inet/com.ibm.streamsx.inet.http/*/*.gif
1416

1517
samples/*/output
1618
samples/*/toolkit.xml

com.ibm.streamsx.inet/build.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ artifacts were left around and caused issues with the ant build.
9292
<target name="cpp">
9393
<exec executable="make" failonerror="true" dir="impl">
9494
<arg value="-f" />
95-
<arg value="Makefile.libftp" />
95+
<arg value="Makefile" />
9696
<arg value="all" />
9797
</exec>
9898
</target>
9999

100100
<target name="cpp-clean">
101101
<exec executable="make" failonerror="true" dir="impl">
102102
<arg value="-f" />
103-
<arg value="Makefile.libftp" />
103+
<arg value="Makefile" />
104104
<arg value="clean" />
105105
</exec>
106106
</target>

com.ibm.streamsx.inet/com.ibm.streamsx.inet.ftp/FTPCommand/FTPCommand.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ The command string and the command arguments are received from port 0.
7878
<library>
7979
<cmn:description>FTP wrapper lib</cmn:description>
8080
<cmn:managedLibrary>
81-
<cmn:lib>ftpwrapper</cmn:lib>
81+
<cmn:lib>inettoolkit</cmn:lib>
8282
<cmn:libPath>../../impl/lib</cmn:libPath>
8383
<cmn:includePath>../../impl/cpp/include/libftp</cmn:includePath>
8484
</cmn:managedLibrary>

com.ibm.streamsx.inet/com.ibm.streamsx.inet.ftp/FTPPutFile/FTPPutFile.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ You can optionally rename the file after you complete the transfer.</description
104104
<library>
105105
<cmn:description>FTP wrapper lib</cmn:description>
106106
<cmn:managedLibrary>
107-
<cmn:lib>ftpwrapper</cmn:lib>
107+
<cmn:lib>inettoolkit</cmn:lib>
108108
<cmn:libPath>../../impl/lib</cmn:libPath>
109109
<cmn:includePath>../../impl/cpp/include/libftp</cmn:includePath>
110110
</cmn:managedLibrary>

com.ibm.streamsx.inet/com.ibm.streamsx.inet.ftp/FTPReader/FTPReader.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ character. An complete empty line indicates an empty file. This function must no
127127
<library>
128128
<cmn:description>FTP wrapper lib</cmn:description>
129129
<cmn:managedLibrary>
130-
<cmn:lib>ftpwrapper</cmn:lib>
130+
<cmn:lib>inettoolkit</cmn:lib>
131131
<cmn:libPath>../../impl/lib</cmn:libPath>
132132
<cmn:includePath>../../impl/cpp/include/libftp</cmn:includePath>
133133
</cmn:managedLibrary>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="ASCII"?>
2+
<function:functionModel xmlns:common="http://www.ibm.com/xmlns/prod/streams/spl/common" xmlns:function="http://www.ibm.com/xmlns/prod/streams/spl/function">
3+
<function:functionSet>
4+
<function:headerFileName>httpFunctions.h</function:headerFileName>
5+
<function:cppNamespaceName>com_ibm_streamsx_inet_http</function:cppNamespaceName>
6+
<function:functions>
7+
<function:function>
8+
<function:description>HTTP GET on the given url, using the username and password, if present. It follows redirects. If there is an error, a non-zero is returned by error.</function:description>
9+
<function:prototype cppName="">public rstring httpGet(rstring url,list&lt;rstring> extraHeaders, rstring user, rstring password, mutable int32 error)</function:prototype>
10+
</function:function>
11+
<function:function>
12+
<function:description>HTTP DELETE on the given url, using the username and password, if present. It follows redirects. If there is an error, a non-zero is returned by error.</function:description>
13+
<function:prototype cppName="">public rstring httpDelete(rstring url,list&lt;rstring> extraHeaders, rstring user, rstring password, mutable int32 error)</function:prototype>
14+
</function:function>
15+
<function:function>
16+
<function:description>HTTP PUT data to the given url using the username and password given if not empty. Does not follow redirects. Headers are returned in the headers list, error is set to a non-zero if there is an error, and the result of the PUT is returned in the rstring.</function:description>
17+
<function:prototype>public rstring httpPut(rstring data, rstring url, list&lt;rstring> extraHeaders, rstring username, rstring password, mutable list&lt;rstring> headers, mutable int32 error)</function:prototype>
18+
</function:function>
19+
<function:function>
20+
<function:description>HTTP POST data to the given url using the username and password (if non-empty). Does not follow redirects. Headers are returned in the headers list. Error is set to non-zero if there is an error. The result of the POST is returned as an rstring. </function:description>
21+
<function:prototype>public rstring httpPost(rstring data, rstring url, list&lt;rstring> extraHeaders, rstring username, rstring password, mutable list&lt;rstring> headers, mutable int32 error)</function:prototype>
22+
</function:function>
23+
<function:function>
24+
<function:description>Decode a URL encoded rstring.</function:description>
25+
<function:prototype>public rstring urlDecode(rstring decode)</function:prototype>
26+
</function:function>
27+
<function:function>
28+
<function:description>URL encode the given rstring.</function:description>
29+
<function:prototype>public rstring urlEncode(rstring raw)</function:prototype>
30+
</function:function>
31+
</function:functions>
32+
<function:dependencies>
33+
<function:library>
34+
<common:description></common:description>
35+
<common:managedLibrary>
36+
<common:lib>curl</common:lib>
37+
<common:lib>inettoolkit</common:lib>
38+
<common:libPath>../../impl/lib</common:libPath>
39+
<common:includePath>../../impl/cpp/include</common:includePath>
40+
</common:managedLibrary>
41+
</function:library>
42+
</function:dependencies>
43+
</function:functionSet>
44+
</function:functionModel>

com.ibm.streamsx.inet/impl/Makefile.libftp renamed to com.ibm.streamsx.inet/impl/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ SPL_LINK_OPTIONS = $(shell $(SPL_PKGCFG) --libs $(SPL_PKG))
1919
# Folders
2020
# -----------------------------------------------------------------------------
2121
TRG := .
22-
INC:= $(TRG)/cpp/include/libftp
22+
INC:= $(TRG)/cpp/include
2323
LIB := $(TRG)/lib
24-
OBJ := $(TRG)/cpp/obj/libftp
25-
SRC := $(TRG)/cpp/src/libftp
24+
OBJ := $(TRG)/cpp/bin
25+
SRC := $(TRG)/cpp/src
2626

2727
# -----------------------------------------------------------------------------
2828
# phony targets are targets being not in the filesystem but are always "active"
@@ -34,7 +34,7 @@ SRC := $(TRG)/cpp/src/libftp
3434
# Library
3535
# -----------------------------------------------------------------------------
3636

37-
LIBRARY := $(LIB)/libftpwrapper.so
37+
LIBRARY := $(LIB)/libinettoolkit.so
3838

3939
# -----------------------------------------------------------------------------
4040
# Helpers
@@ -55,7 +55,7 @@ $(LIB) $(OBJ):
5555

5656
$(OBJ)/%.o: $(SRC)/%.cpp $(INCLUDES)
5757
@echo Compiling '$<' ...
58-
$(CXX) $(CXXFLAGS) -c $< -o $@
58+
$(CXX) $(CXXFLAGS) -c $< -o $@ -I $(INC)
5959

6060
$(LIBRARY): $(LIB) $(OBJ) $(OBJECTS)
6161
@echo Building C++ shared library '$@'
@@ -78,4 +78,4 @@ help:
7878
@echo "all: clean build this is the default target"
7979
@echo "clean: remove library and object files"
8080
@echo "build: build the library"
81-
81+

com.ibm.streamsx.inet/impl/cpp/include/libftp/FTPWrapper.h renamed to com.ibm.streamsx.inet/impl/cpp/include/FTPWrapper.h

File renamed without changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef HTTP_FOR_STREAMS
2+
#define HTTP_FOR_STREAMS
3+
#include "curl/curl.h"
4+
#include <SPL/Runtime/Type/Blob.h>
5+
#include <SPL/Runtime/Type/List.h>
6+
7+
namespace com_ibm_streamsx_inet_http {
8+
9+
10+
// We're just writing bytes.
11+
size_t populate_rstring(char *ptr,size_t size, size_t nmemb, void*userdata);
12+
13+
SPL::rstring httpGet(const SPL::rstring & url, const SPL::list<SPL::rstring> & extraHeaders, const SPL::rstring & username, const SPL::rstring & password,SPL::int32 & error);
14+
15+
SPL::rstring httpDelete(const SPL::rstring & url, const SPL::list<SPL::rstring> & extraHeaders, const SPL::rstring & username, const SPL::rstring & password, SPL::int32 & error);
16+
17+
SPL::rstring httpPut(const SPL::rstring & data, const SPL::rstring & url, const SPL::list<SPL::rstring> & extraHeaders, const SPL::rstring & username, const SPL::rstring & password, SPL::list<SPL::rstring>& headers, SPL::int32 & error);
18+
19+
SPL::rstring httpPost(const SPL::rstring & data, const SPL::rstring & url, const SPL::list<SPL::rstring> & extraHeaders, const SPL::rstring & username, const SPL::rstring & password, SPL::list<SPL::rstring>& headers, SPL::int32 & error);
20+
21+
22+
SPL::rstring urlEncode(const SPL::rstring & raw);
23+
24+
SPL::rstring urlDecode(const SPL::rstring & encoded);
25+
26+
27+
}
28+
#endif

com.ibm.streamsx.inet/impl/cpp/src/libftp/FTPWrapper.cpp renamed to com.ibm.streamsx.inet/impl/cpp/src/FTPWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* Copyright (C) 2013-2014, International Business Machines Corporation */
22
/* All Rights Reserved */
33

4-
#include "../../include/libftp/FTPWrapper.h"
4+
#include "FTPWrapper.h"
55
#include <SPL/Runtime/Common/RuntimeException.h>
66
#include <cstdio>
77
#include <iostream>

0 commit comments

Comments
 (0)