aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-02-24 01:31:48 +0000
committerMike Buland <eichlan@xagasoft.com>2009-02-24 01:31:48 +0000
commit22277c6ffe91189cbb5d7a7d8572bf829e3a2610 (patch)
tree5e9d2a7aa1e1d2c2efe8696ff174d125de6051a4
parent88b3a5acf78aa9a2d73f2462e45988f5afb9d2c5 (diff)
downloadlibbu++-22277c6ffe91189cbb5d7a7d8572bf829e3a2610.tar.gz
libbu++-22277c6ffe91189cbb5d7a7d8572bf829e3a2610.tar.bz2
libbu++-22277c6ffe91189cbb5d7a7d8572bf829e3a2610.tar.xz
libbu++-22277c6ffe91189cbb5d7a7d8572bf829e3a2610.zip
Just committing some in-progress code. It may report some warnings, but it
doesn't inhibit building. These'll be in good working shape in no time.
-rw-r--r--src/buffer.cpp17
-rw-r--r--src/buffer.h33
-rw-r--r--src/httpget.cpp103
-rw-r--r--src/httpget.h54
4 files changed, 207 insertions, 0 deletions
diff --git a/src/buffer.cpp b/src/buffer.cpp
new file mode 100644
index 0000000..abb4fed
--- /dev/null
+++ b/src/buffer.cpp
@@ -0,0 +1,17 @@
1#include "bu/buffer.h"
2
3Bu::Buffer::Buffer( Bu::Stream &rNext, int iBufsize ) :
4 Bu::Filter( rNext ),
5 sSoFar( 0 ),
6 iBufSize( iBufSize ),
7 sReadBuf( NULL ),
8 sWriteBuf( NULL ),
9 iReadBufFill( 0 ),
10 iWriteBufFill( 0 )
11{
12}
13
14Bu::Buffer::~Buffer()
15{
16}
17
diff --git a/src/buffer.h b/src/buffer.h
new file mode 100644
index 0000000..beb4b08
--- /dev/null
+++ b/src/buffer.h
@@ -0,0 +1,33 @@
1#ifndef BU_BUFFER_H
2#define BU_BUFFER_H
3
4#include "bu/filter.h"
5
6namespace Bu
7{
8 class Buffer : public Bu::Filter
9 {
10 public:
11 Buffer( Bu::Stream &rNext, int iBufSize=4096 );
12 virtual ~Buffer();
13
14 virtual void start();
15 virtual size_t stop();
16
17 virtual size_t read( void *pBuf, size_t nBytes );
18 virtual size_t write( const void *pBuf, size_t nBytes );
19 using Stream::write;
20
21 virtual void flush();
22
23 private:
24 size_t sSoFar;
25 int iBufSize;
26 char *sReadBuf;
27 char *sWriteBuf;
28 int iReadBufFill;
29 int iWriteBufFill;
30 };
31};
32
33#endif
diff --git a/src/httpget.cpp b/src/httpget.cpp
new file mode 100644
index 0000000..c5aa16d
--- /dev/null
+++ b/src/httpget.cpp
@@ -0,0 +1,103 @@
1#include "bu/httpget.h"
2
3Bu::HttpGet::HttpGet( const Bu::Url &uSrc, const Bu::FString &sMethod ) :
4 uSrc( uSrc ),
5 sMethod( sMethod ),
6 sSrv( uSrc.getHost(), uSrc.getPort() )
7{
8 sSrv.write( sMethod + " " + uSrc.getFullPath() + " HTTP/1.1\r\n" );
9}
10
11Bu::HttpGet::~HttpGet()
12{
13}
14
15void Bu::HttpGet::close()
16{
17}
18
19void Bu::HttpGet::get()
20{
21 for( MimeHash::iterator i = hMimeOut.begin(); i; i++ )
22 {
23 sSrv.write( i.getKey() + ": " + i.getValue() + "\r\n" );
24 }
25 sSrv.write("\r\n", 2 );
26
27// sSrv.read(
28}
29
30size_t Bu::HttpGet::read( void *pBuf, size_t nBytes )
31{
32}
33
34size_t Bu::HttpGet::write( const void *pBuf, size_t nBytes )
35{
36 return 0;
37}
38
39long Bu::HttpGet::tell()
40{
41 return 0;
42}
43
44void Bu::HttpGet::seek( long )
45{
46}
47
48void Bu::HttpGet::setPos( long )
49{
50}
51
52void Bu::HttpGet::setPosEnd( long )
53{
54}
55
56bool Bu::HttpGet::isEOS()
57{
58 return false;
59}
60
61bool Bu::HttpGet::isOpen()
62{
63 return true;
64}
65
66void Bu::HttpGet::flush()
67{
68}
69
70bool Bu::HttpGet::canRead()
71{
72 return true;
73}
74
75bool Bu::HttpGet::canWrite()
76{
77 return false;
78}
79
80bool Bu::HttpGet::isReadable()
81{
82 return true;
83}
84
85bool Bu::HttpGet::isWritable()
86{
87 return false;
88}
89
90bool Bu::HttpGet::isSeekable()
91{
92 return false;
93}
94
95bool Bu::HttpGet::isBlocking()
96{
97 return true;
98}
99
100void Bu::HttpGet::setBlocking( bool /*bBlocking*/ )
101{
102}
103
diff --git a/src/httpget.h b/src/httpget.h
new file mode 100644
index 0000000..25f5ab1
--- /dev/null
+++ b/src/httpget.h
@@ -0,0 +1,54 @@
1#ifndef BU_HTTP_GET_H
2#define BU_HTTP_GET_H
3
4#include "bu/stream.h"
5#include "bu/fstring.h"
6#include "bu/url.h"
7#include "bu/socket.h"
8
9namespace Bu
10{
11 class HttpGet : public Bu::Stream
12 {
13 public:
14 HttpGet( const Bu::Url &uSrc, const Bu::FString &sMethod="GET" );
15 virtual ~HttpGet();
16
17 void get();
18
19 // From Bu::Stream
20 virtual void close();
21 virtual size_t read( void *pBuf, size_t nBytes );
22 virtual size_t write( const void *pBuf, size_t nBytes );
23 using Stream::write;
24
25 virtual long tell();
26 virtual void seek( long offset );
27 virtual void setPos( long pos );
28 virtual void setPosEnd( long pos );
29 virtual bool isEOS();
30 virtual bool isOpen();
31
32 virtual void flush();
33
34 virtual bool canRead();
35 virtual bool canWrite();
36
37 virtual bool isReadable();
38 virtual bool isWritable();
39 virtual bool isSeekable();
40
41 virtual bool isBlocking();
42 virtual void setBlocking( bool bBlocking=true );
43
44 private:
45 Bu::Url uSrc;
46 Bu::FString sMethod;
47 Bu::Socket sSrv;
48 typedef Bu::Hash<Bu::FString,Bu::FString> MimeHash;
49 MimeHash hMimeIn;
50 MimeHash hMimeOut;
51 };
52};
53
54#endif