Net::OBEX::Packet::Headers - construct and parse OBEX packet headers
use strict; use warnings; use Net::OBEX::Packet::Headers; # this would be the data from the socket. my $header = pack 'H*', '4a0013f9ec7bc4953c11d2984e525400dc9e09cb00000001'; my $head = Net::OBEX::Packet::Headers->new; my $parse_ref = $head->parse( $header ); my @headers = keys %$parse_ref; print "Your data containts " . @headers . " headers which are: \n", map { "[$_]\n" } @headers; my $type_header = $head->make( 'target' => pack 'H*', 'F9EC7BC4953C11D2984E525400DC9E09' ); printf "Type header for OBEX FTP (F9EC7BC4953C11D2984E525400DC9E09) " . "in hex is: \n%s\n", unpack 'H*', $type_header; print "Let's see what the parse says... \n"; $head->parse( $type_header ); print map { "$_ => " . uc unpack( 'H*', $parse_ref->{$_}) . "\n" } keys %{ $head->headers_parsed };
WARNING!!! This module is still in alpha stage. Use it for test purposes only as interface might change in the future.
The module provides means to create OBEX protocol packet headers as well as means to parse the data containing headers.
my $head = Net::OBEX::Packet::Headers->new; my $head = Net::OBEX::Packet::Headers->new( $raw_headers );
Constructs and returns a Net::OBEX::Packet::Headers object. Takes one optional argument which is raw data containing headers you would want to parse.
my $parse_ref = $head->parse; my $parse_ref = $head->parse( $raw_headers );
Instructs the object to parse raw data containing OBEX headers. Returns a hashref, keys of which will be the names of OBEX headers found in the data and value will be the values of each of those headers.
Takes one optional argument which is a scalar containing raw OBEX headers, if this argument is not specified will parse whatever data you've specified in the constructor. The possible header names in the return hashref are the same as the names of the headers to make() method "header name" argument. Note: parsing of custom, i.e. "user defined" headers is not implemented yet.
make()
my $type_header = $head->make( 'target' => pack 'H*', 'F9EC7BC4953C11D2984E525400DC9E09' ); my $name_header = $head->make( 'name' => 'x-obex/folder-listing' );
Constructs an OBEX header suitable to go down the wire. Takes two arguments the name of the header and its value. If you wish to specify a header with no value use an empty string as a value, e.g.:
my $set_path_root_name_header = $head->make( 'name' => '' );
Possible header names are as follows:
The COUNT header.
COUNT
The LENGTH header.
LENGTH
The TIME header in its byte sequence format.
TIME
The TIME header in its 4-byte format.
The Connection ID header.
Connection ID
The TYPE header.
TYPE
The TARGET header.
TARGET
The HTTP header.
HTTP
The WHO header.
WHO
The Application Parameters header.
Application Parameters
The Authentication Challenge header.
Authentication Challenge
The Authentication Response header.
Authentication Response
The BODY header.
BODY
The End Of Body header.
End Of Body
The Object Class header.
Object Class
The NAME header.
NAME
Te Description header.
Description
Note: If you want to create custom headers take a look at either Net::OBEX::Packet::Headers::Unicode, Net::OBEX::Packet::Headers::ByteSeq, Net::OBEX::Packet::Headers::Byte4 or Net::OBEX::Packet::Headers::Byte1 modules depending on which type of header you want to create.
my $raw = $head->headers_raw;
Takes no arguments, returns the raw headers data you've supplied to the constructor or last parse() call.
parse()
my $parse_ref = $head->headers_parsed;
Must be called after the call to parse(). Takes no arguments, returns the hashref of parsed headers, same as the return value of parse(). See parse() method for more information.
Fork this module on GitHub: https://github.com/zoffixznet/Net-OBEX
To report bugs or request features, please use https://github.com/zoffixznet/Net-OBEX/issues
If you can't access GitHub, you can email your request to bug-Net-OBEX at rt.cpan.org
bug-Net-OBEX at rt.cpan.org
Zoffix Znet <zoffix at cpan.org> (http://zoffix.com/, http://haslayout.net/)
You can use and distribute this module under the same terms as Perl itself. See the LICENSE file included in this distribution for complete details.
LICENSE
To install Net::OBEX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::OBEX
CPAN shell
perl -MCPAN -e shell install Net::OBEX
For more information on module installation, please visit the detailed CPAN module installation guide.