Committer:
donatien
Date:
Fri Jul 06 10:22:15 2012 +0000
Revision:
0:7aca7353eebf
Fixed parseURL issue for port parsing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:7aca7353eebf 1 /* HTTPText.cpp */
donatien 0:7aca7353eebf 2 /*
donatien 0:7aca7353eebf 3 Copyright (C) 2012 ARM Limited.
donatien 0:7aca7353eebf 4
donatien 0:7aca7353eebf 5 Permission is hereby granted, free of charge, to any person obtaining a copy of
donatien 0:7aca7353eebf 6 this software and associated documentation files (the "Software"), to deal in
donatien 0:7aca7353eebf 7 the Software without restriction, including without limitation the rights to
donatien 0:7aca7353eebf 8 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
donatien 0:7aca7353eebf 9 of the Software, and to permit persons to whom the Software is furnished to do
donatien 0:7aca7353eebf 10 so, subject to the following conditions:
donatien 0:7aca7353eebf 11
donatien 0:7aca7353eebf 12 The above copyright notice and this permission notice shall be included in all
donatien 0:7aca7353eebf 13 copies or substantial portions of the Software.
donatien 0:7aca7353eebf 14
donatien 0:7aca7353eebf 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
donatien 0:7aca7353eebf 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
donatien 0:7aca7353eebf 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
donatien 0:7aca7353eebf 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
donatien 0:7aca7353eebf 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 0:7aca7353eebf 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
donatien 0:7aca7353eebf 21 SOFTWARE.
donatien 0:7aca7353eebf 22 */
donatien 0:7aca7353eebf 23
donatien 0:7aca7353eebf 24 #include "core/fwk.h"
donatien 0:7aca7353eebf 25
donatien 0:7aca7353eebf 26 #include "HTTPText.h"
donatien 0:7aca7353eebf 27
donatien 0:7aca7353eebf 28 #include <cstring>
donatien 0:7aca7353eebf 29
donatien 0:7aca7353eebf 30 HTTPText::HTTPText(char* str) : m_str(str), m_pos(0)
donatien 0:7aca7353eebf 31 {
donatien 0:7aca7353eebf 32 m_size = strlen(str) + 1;
donatien 0:7aca7353eebf 33 }
donatien 0:7aca7353eebf 34
donatien 0:7aca7353eebf 35 HTTPText::HTTPText(char* str, size_t size) : m_str(str), m_size(size), m_pos(0)
donatien 0:7aca7353eebf 36 {
donatien 0:7aca7353eebf 37
donatien 0:7aca7353eebf 38 }
donatien 0:7aca7353eebf 39
donatien 0:7aca7353eebf 40 //IHTTPDataIn
donatien 0:7aca7353eebf 41 /*virtual*/ int HTTPText::read(char* buf, size_t len, size_t* pReadLen)
donatien 0:7aca7353eebf 42 {
donatien 0:7aca7353eebf 43 *pReadLen = MIN(len, m_size - 1 - m_pos);
donatien 0:7aca7353eebf 44 memcpy(buf, m_str + m_pos, *pReadLen);
donatien 0:7aca7353eebf 45 m_pos += *pReadLen;
donatien 0:7aca7353eebf 46 return OK;
donatien 0:7aca7353eebf 47 }
donatien 0:7aca7353eebf 48
donatien 0:7aca7353eebf 49 /*virtual*/ int HTTPText::getDataType(char* type, size_t maxTypeLen) //Internet media type for Content-Type header
donatien 0:7aca7353eebf 50 {
donatien 0:7aca7353eebf 51 strncpy(type, "text/plain", maxTypeLen-1);
donatien 0:7aca7353eebf 52 type[maxTypeLen-1] = '\0';
donatien 0:7aca7353eebf 53 return OK;
donatien 0:7aca7353eebf 54 }
donatien 0:7aca7353eebf 55
donatien 0:7aca7353eebf 56 /*virtual*/ bool HTTPText::getIsChunked() //For Transfer-Encoding header
donatien 0:7aca7353eebf 57 {
donatien 0:7aca7353eebf 58 return false;
donatien 0:7aca7353eebf 59 }
donatien 0:7aca7353eebf 60
donatien 0:7aca7353eebf 61 /*virtual*/ size_t HTTPText::getDataLen() //For Content-Length header
donatien 0:7aca7353eebf 62 {
donatien 0:7aca7353eebf 63 return m_size - 1;
donatien 0:7aca7353eebf 64 }
donatien 0:7aca7353eebf 65
donatien 0:7aca7353eebf 66 //IHTTPDataOut
donatien 0:7aca7353eebf 67 /*virtual*/ int HTTPText::write(const char* buf, size_t len)
donatien 0:7aca7353eebf 68 {
donatien 0:7aca7353eebf 69 size_t writeLen = MIN(len, m_size - 1 - m_pos);
donatien 0:7aca7353eebf 70 memcpy(m_str + m_pos, buf, writeLen);
donatien 0:7aca7353eebf 71 m_pos += writeLen;
donatien 0:7aca7353eebf 72 m_str[m_pos] = '\0';
donatien 0:7aca7353eebf 73 return OK;
donatien 0:7aca7353eebf 74 }
donatien 0:7aca7353eebf 75
donatien 0:7aca7353eebf 76 /*virtual*/ void HTTPText::setDataType(const char* type) //Internet media type from Content-Type header
donatien 0:7aca7353eebf 77 {
donatien 0:7aca7353eebf 78
donatien 0:7aca7353eebf 79 }
donatien 0:7aca7353eebf 80
donatien 0:7aca7353eebf 81 /*virtual*/ void HTTPText::setIsChunked(bool chunked) //From Transfer-Encoding header
donatien 0:7aca7353eebf 82 {
donatien 0:7aca7353eebf 83
donatien 0:7aca7353eebf 84 }
donatien 0:7aca7353eebf 85
donatien 0:7aca7353eebf 86 /*virtual*/ void HTTPText::setDataLen(size_t len) //From Content-Length header, or if the transfer is chunked, next chunk length
donatien 0:7aca7353eebf 87 {
donatien 0:7aca7353eebf 88
donatien 0:7aca7353eebf 89 }
donatien 0:7aca7353eebf 90
donatien 0:7aca7353eebf 91
donatien 0:7aca7353eebf 92