Modified version of NetServices. Fixes an issue where connections failed should the HTTP response status line be received in a packet on its own prior to any further headers. Changes are made to the HTTPClient.cpp file's readHeaders method.

Committer:
andrewbonney
Date:
Fri Apr 08 14:39:41 2011 +0000
Revision:
0:ec559500a63f

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewbonney 0:ec559500a63f 1 /**
andrewbonney 0:ec559500a63f 2 * @file
andrewbonney 0:ec559500a63f 3 * Common functions used throughout the stack.
andrewbonney 0:ec559500a63f 4 *
andrewbonney 0:ec559500a63f 5 */
andrewbonney 0:ec559500a63f 6
andrewbonney 0:ec559500a63f 7 /*
andrewbonney 0:ec559500a63f 8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
andrewbonney 0:ec559500a63f 9 * All rights reserved.
andrewbonney 0:ec559500a63f 10 *
andrewbonney 0:ec559500a63f 11 * Redistribution and use in source and binary forms, with or without modification,
andrewbonney 0:ec559500a63f 12 * are permitted provided that the following conditions are met:
andrewbonney 0:ec559500a63f 13 *
andrewbonney 0:ec559500a63f 14 * 1. Redistributions of source code must retain the above copyright notice,
andrewbonney 0:ec559500a63f 15 * this list of conditions and the following disclaimer.
andrewbonney 0:ec559500a63f 16 * 2. Redistributions in binary form must reproduce the above copyright notice,
andrewbonney 0:ec559500a63f 17 * this list of conditions and the following disclaimer in the documentation
andrewbonney 0:ec559500a63f 18 * and/or other materials provided with the distribution.
andrewbonney 0:ec559500a63f 19 * 3. The name of the author may not be used to endorse or promote products
andrewbonney 0:ec559500a63f 20 * derived from this software without specific prior written permission.
andrewbonney 0:ec559500a63f 21 *
andrewbonney 0:ec559500a63f 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
andrewbonney 0:ec559500a63f 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
andrewbonney 0:ec559500a63f 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
andrewbonney 0:ec559500a63f 25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
andrewbonney 0:ec559500a63f 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
andrewbonney 0:ec559500a63f 27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
andrewbonney 0:ec559500a63f 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
andrewbonney 0:ec559500a63f 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
andrewbonney 0:ec559500a63f 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
andrewbonney 0:ec559500a63f 31 * OF SUCH DAMAGE.
andrewbonney 0:ec559500a63f 32 *
andrewbonney 0:ec559500a63f 33 * This file is part of the lwIP TCP/IP stack.
andrewbonney 0:ec559500a63f 34 *
andrewbonney 0:ec559500a63f 35 * Author: Simon Goldschmidt
andrewbonney 0:ec559500a63f 36 *
andrewbonney 0:ec559500a63f 37 */
andrewbonney 0:ec559500a63f 38
andrewbonney 0:ec559500a63f 39 #include "lwip/opt.h"
andrewbonney 0:ec559500a63f 40 #include "lwip/def.h"
andrewbonney 0:ec559500a63f 41
andrewbonney 0:ec559500a63f 42 /**
andrewbonney 0:ec559500a63f 43 * These are reference implementations of the byte swapping functions.
andrewbonney 0:ec559500a63f 44 * Again with the aim of being simple, correct and fully portable.
andrewbonney 0:ec559500a63f 45 * Byte swapping is the second thing you would want to optimize. You will
andrewbonney 0:ec559500a63f 46 * need to port it to your architecture and in your cc.h:
andrewbonney 0:ec559500a63f 47 *
andrewbonney 0:ec559500a63f 48 * #define LWIP_PLATFORM_BYTESWAP 1
andrewbonney 0:ec559500a63f 49 * #define LWIP_PLATFORM_HTONS(x) <your_htons>
andrewbonney 0:ec559500a63f 50 * #define LWIP_PLATFORM_HTONL(x) <your_htonl>
andrewbonney 0:ec559500a63f 51 *
andrewbonney 0:ec559500a63f 52 * Note ntohs() and ntohl() are merely references to the htonx counterparts.
andrewbonney 0:ec559500a63f 53 */
andrewbonney 0:ec559500a63f 54
andrewbonney 0:ec559500a63f 55 #if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN)
andrewbonney 0:ec559500a63f 56
andrewbonney 0:ec559500a63f 57 /**
andrewbonney 0:ec559500a63f 58 * Convert an u16_t from host- to network byte order.
andrewbonney 0:ec559500a63f 59 *
andrewbonney 0:ec559500a63f 60 * @param n u16_t in host byte order
andrewbonney 0:ec559500a63f 61 * @return n in network byte order
andrewbonney 0:ec559500a63f 62 */
andrewbonney 0:ec559500a63f 63 u16_t
andrewbonney 0:ec559500a63f 64 lwip_htons(u16_t n)
andrewbonney 0:ec559500a63f 65 {
andrewbonney 0:ec559500a63f 66 return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
andrewbonney 0:ec559500a63f 67 }
andrewbonney 0:ec559500a63f 68
andrewbonney 0:ec559500a63f 69 /**
andrewbonney 0:ec559500a63f 70 * Convert an u16_t from network- to host byte order.
andrewbonney 0:ec559500a63f 71 *
andrewbonney 0:ec559500a63f 72 * @param n u16_t in network byte order
andrewbonney 0:ec559500a63f 73 * @return n in host byte order
andrewbonney 0:ec559500a63f 74 */
andrewbonney 0:ec559500a63f 75 u16_t
andrewbonney 0:ec559500a63f 76 lwip_ntohs(u16_t n)
andrewbonney 0:ec559500a63f 77 {
andrewbonney 0:ec559500a63f 78 return lwip_htons(n);
andrewbonney 0:ec559500a63f 79 }
andrewbonney 0:ec559500a63f 80
andrewbonney 0:ec559500a63f 81 /**
andrewbonney 0:ec559500a63f 82 * Convert an u32_t from host- to network byte order.
andrewbonney 0:ec559500a63f 83 *
andrewbonney 0:ec559500a63f 84 * @param n u32_t in host byte order
andrewbonney 0:ec559500a63f 85 * @return n in network byte order
andrewbonney 0:ec559500a63f 86 */
andrewbonney 0:ec559500a63f 87 u32_t
andrewbonney 0:ec559500a63f 88 lwip_htonl(u32_t n)
andrewbonney 0:ec559500a63f 89 {
andrewbonney 0:ec559500a63f 90 return ((n & 0xff) << 24) |
andrewbonney 0:ec559500a63f 91 ((n & 0xff00) << 8) |
andrewbonney 0:ec559500a63f 92 ((n & 0xff0000UL) >> 8) |
andrewbonney 0:ec559500a63f 93 ((n & 0xff000000UL) >> 24);
andrewbonney 0:ec559500a63f 94 }
andrewbonney 0:ec559500a63f 95
andrewbonney 0:ec559500a63f 96 /**
andrewbonney 0:ec559500a63f 97 * Convert an u32_t from network- to host byte order.
andrewbonney 0:ec559500a63f 98 *
andrewbonney 0:ec559500a63f 99 * @param n u32_t in network byte order
andrewbonney 0:ec559500a63f 100 * @return n in host byte order
andrewbonney 0:ec559500a63f 101 */
andrewbonney 0:ec559500a63f 102 u32_t
andrewbonney 0:ec559500a63f 103 lwip_ntohl(u32_t n)
andrewbonney 0:ec559500a63f 104 {
andrewbonney 0:ec559500a63f 105 return lwip_htonl(n);
andrewbonney 0:ec559500a63f 106 }
andrewbonney 0:ec559500a63f 107
andrewbonney 0:ec559500a63f 108 #endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */