YARP
Yet Another Robot Platform
yarp::os::impl::HttpTwoWayStream Class Reference

Minimal http connection support. More...

#include <yarp/os/impl/HttpCarrier.h>

+ Inheritance diagram for yarp::os::impl::HttpTwoWayStream:

Public Member Functions

 HttpTwoWayStream (TwoWayStream *delegate, const char *txt, const char *prefix, yarp::os::Property &prop, bool writer)
 
virtual ~HttpTwoWayStream ()
 
InputStreamgetInputStream () override
 Get an InputStream to read from. More...
 
OutputStreamgetOutputStream () override
 Get an OutputStream to write to. More...
 
const ContactgetLocalAddress () const override
 Get the address of the local side of the stream. More...
 
const ContactgetRemoteAddress () const override
 Get the address of the remote side of the stream. More...
 
bool isOk () const override
 Check if the stream is ok or in an error state. More...
 
void reset () override
 Reset the stream. More...
 
void write (const Bytes &b) override
 Write a block of bytes to the stream. More...
 
virtual void apply (char ch)
 
void close () override
 Terminate the stream. More...
 
void beginPacket () override
 Mark the beginning of a logical packet. More...
 
void endPacket () override
 Mark the end of a logical packet (see beginPacket). More...
 
void flip ()
 
void finish ()
 
bool useJson ()
 
std::string * typeHint ()
 
- Public Member Functions inherited from yarp::os::TwoWayStream
virtual ~TwoWayStream ()
 Destructor. More...
 
- Public Member Functions inherited from yarp::os::OutputStream
virtual ~OutputStream ()
 Destructor. More...
 
virtual void write (char ch)
 Write a single byte to the stream. More...
 
virtual void write (const Bytes &b, int offset, int len)
 Write a block of bytes to the stream. More...
 
virtual void flush ()
 Make sure all pending write operations are finished. More...
 
virtual void writeLine (const char *data, int len)
 Write some text followed by a line feed. More...
 
virtual bool setWriteTimeout (double timeout)
 Set activity timeout. More...
 
virtual bool setTypeOfService (int tos)
 
virtual int getTypeOfService ()
 

Detailed Description

Minimal http connection support.

Most useful for connections to YARP ports from browsers. No support for connections in the opposite direction. This carrier is recruited when a port sees a TCP stream that begins with "GET /".

For "GET /", the URL following the "/" is currently translated to text as follows: ", " becomes newline "+" becomes " " This text is then passed on to the port, just as for a normal text connection. For example "GET /d, list" is the same as telnetting into a port and typing: CONNECT anon d list or typing "list" to "yarp rpc /portname". The response of the port, if any, is output in ugly html.

For "POST /" ... not done yet.

Definition at line 48 of file HttpCarrier.h.

Constructor & Destructor Documentation

◆ HttpTwoWayStream()

yarp::os::impl::HttpTwoWayStream::HttpTwoWayStream ( TwoWayStream delegate,
const char *  txt,
const char *  prefix,
yarp::os::Property prop,
bool  writer 
)

Definition at line 170 of file HttpCarrier.cpp.

◆ ~HttpTwoWayStream()

yarp::os::impl::HttpTwoWayStream::~HttpTwoWayStream ( )
virtual

Definition at line 355 of file HttpCarrier.cpp.

Member Function Documentation

◆ apply()

void yarp::os::impl::HttpTwoWayStream::apply ( char  ch)
virtual

Definition at line 404 of file HttpCarrier.cpp.

◆ beginPacket()

void yarp::os::impl::HttpTwoWayStream::beginPacket ( )
overridevirtual

Mark the beginning of a logical packet.

This is a unit that should be treated in an atomic fashion by YARP. If any part is corrupted, the whole should be dropped.

Implements yarp::os::TwoWayStream.

Definition at line 506 of file HttpCarrier.cpp.

◆ close()

void yarp::os::impl::HttpTwoWayStream::close ( )
overridevirtual

Terminate the stream.

Implements yarp::os::OutputStream.

Definition at line 499 of file HttpCarrier.cpp.

◆ endPacket()

void yarp::os::impl::HttpTwoWayStream::endPacket ( )
overridevirtual

Mark the end of a logical packet (see beginPacket).

Implements yarp::os::TwoWayStream.

Definition at line 511 of file HttpCarrier.cpp.

◆ finish()

void yarp::os::impl::HttpTwoWayStream::finish ( )

Definition at line 521 of file HttpCarrier.cpp.

◆ flip()

void yarp::os::impl::HttpTwoWayStream::flip ( )

Definition at line 516 of file HttpCarrier.cpp.

◆ getInputStream()

yarp::os::InputStream & yarp::os::impl::HttpTwoWayStream::getInputStream ( )
overridevirtual

Get an InputStream to read from.

Returns
the InputStream associated with this object.

Implements yarp::os::TwoWayStream.

Definition at line 363 of file HttpCarrier.cpp.

◆ getLocalAddress()

const Contact & yarp::os::impl::HttpTwoWayStream::getLocalAddress ( ) const
overridevirtual

Get the address of the local side of the stream.

Returns
the address of the local side of the stream. The address will be tagged as invalid if the stream is not set up.

Implements yarp::os::TwoWayStream.

Definition at line 373 of file HttpCarrier.cpp.

◆ getOutputStream()

yarp::os::OutputStream & yarp::os::impl::HttpTwoWayStream::getOutputStream ( )
overridevirtual

Get an OutputStream to write to.

Returns
the InputStream associated with this object.

Implements yarp::os::TwoWayStream.

Definition at line 368 of file HttpCarrier.cpp.

◆ getRemoteAddress()

const Contact & yarp::os::impl::HttpTwoWayStream::getRemoteAddress ( ) const
overridevirtual

Get the address of the remote side of the stream.

Returns
the address of the remote side of the stream. The address will be tagged as invalid if the stream is not set up.

Implements yarp::os::TwoWayStream.

Definition at line 378 of file HttpCarrier.cpp.

◆ isOk()

bool yarp::os::impl::HttpTwoWayStream::isOk ( ) const
overridevirtual

Check if the stream is ok or in an error state.

Returns
true iff the stream is ok

Implements yarp::os::OutputStream.

Definition at line 383 of file HttpCarrier.cpp.

◆ reset()

void yarp::os::impl::HttpTwoWayStream::reset ( )
overridevirtual

Reset the stream.

Implements yarp::os::TwoWayStream.

Definition at line 388 of file HttpCarrier.cpp.

◆ typeHint()

std::string * yarp::os::impl::HttpTwoWayStream::typeHint ( )

Definition at line 531 of file HttpCarrier.cpp.

◆ useJson()

bool yarp::os::impl::HttpTwoWayStream::useJson ( )

Definition at line 526 of file HttpCarrier.cpp.

◆ write()

void yarp::os::impl::HttpTwoWayStream::write ( const Bytes b)
overridevirtual

Write a block of bytes to the stream.

Parameters
bthe bytes to write

Implements yarp::os::OutputStream.

Definition at line 393 of file HttpCarrier.cpp.


The documentation for this class was generated from the following files: