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 * Redistribution and use in source and binary forms, with or without modification,
andrewbonney 0:ec559500a63f 3 * are permitted provided that the following conditions are met:
andrewbonney 0:ec559500a63f 4 *
andrewbonney 0:ec559500a63f 5 * 1. Redistributions of source code must retain the above copyright notice,
andrewbonney 0:ec559500a63f 6 * this list of conditions and the following disclaimer.
andrewbonney 0:ec559500a63f 7 * 2. Redistributions in binary form must reproduce the above copyright notice,
andrewbonney 0:ec559500a63f 8 * this list of conditions and the following disclaimer in the documentation
andrewbonney 0:ec559500a63f 9 * and/or other materials provided with the distribution.
andrewbonney 0:ec559500a63f 10 * 3. The name of the author may not be used to endorse or promote products
andrewbonney 0:ec559500a63f 11 * derived from this software without specific prior written permission.
andrewbonney 0:ec559500a63f 12 *
andrewbonney 0:ec559500a63f 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
andrewbonney 0:ec559500a63f 14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
andrewbonney 0:ec559500a63f 15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
andrewbonney 0:ec559500a63f 16 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
andrewbonney 0:ec559500a63f 17 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
andrewbonney 0:ec559500a63f 18 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
andrewbonney 0:ec559500a63f 19 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
andrewbonney 0:ec559500a63f 20 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
andrewbonney 0:ec559500a63f 21 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
andrewbonney 0:ec559500a63f 22 * OF SUCH DAMAGE.
andrewbonney 0:ec559500a63f 23 *
andrewbonney 0:ec559500a63f 24 * This file is part of the lwIP TCP/IP stack.
andrewbonney 0:ec559500a63f 25 *
andrewbonney 0:ec559500a63f 26 * Author: Simon Goldschmidt
andrewbonney 0:ec559500a63f 27 *
andrewbonney 0:ec559500a63f 28 */
andrewbonney 0:ec559500a63f 29 #ifndef __LWIP_NETDB_H__
andrewbonney 0:ec559500a63f 30 #define __LWIP_NETDB_H__
andrewbonney 0:ec559500a63f 31
andrewbonney 0:ec559500a63f 32 #include "lwip/opt.h"
andrewbonney 0:ec559500a63f 33
andrewbonney 0:ec559500a63f 34 #if LWIP_DNS && LWIP_SOCKET
andrewbonney 0:ec559500a63f 35
andrewbonney 0:ec559500a63f 36 #include <stddef.h> /* for size_t */
andrewbonney 0:ec559500a63f 37
andrewbonney 0:ec559500a63f 38 #include "lwip/inet.h"
andrewbonney 0:ec559500a63f 39 #include "lwip/sockets.h"
andrewbonney 0:ec559500a63f 40
andrewbonney 0:ec559500a63f 41 /* some rarely used options */
andrewbonney 0:ec559500a63f 42 #ifndef LWIP_DNS_API_DECLARE_H_ERRNO
andrewbonney 0:ec559500a63f 43 #define LWIP_DNS_API_DECLARE_H_ERRNO 1
andrewbonney 0:ec559500a63f 44 #endif
andrewbonney 0:ec559500a63f 45
andrewbonney 0:ec559500a63f 46 #ifndef LWIP_DNS_API_DEFINE_ERRORS
andrewbonney 0:ec559500a63f 47 #define LWIP_DNS_API_DEFINE_ERRORS 1
andrewbonney 0:ec559500a63f 48 #endif
andrewbonney 0:ec559500a63f 49
andrewbonney 0:ec559500a63f 50 #ifndef LWIP_DNS_API_DECLARE_STRUCTS
andrewbonney 0:ec559500a63f 51 #define LWIP_DNS_API_DECLARE_STRUCTS 1
andrewbonney 0:ec559500a63f 52 #endif
andrewbonney 0:ec559500a63f 53
andrewbonney 0:ec559500a63f 54 #if LWIP_DNS_API_DEFINE_ERRORS
andrewbonney 0:ec559500a63f 55 /** Errors used by the DNS API functions, h_errno can be one of them */
andrewbonney 0:ec559500a63f 56 #define EAI_NONAME 200
andrewbonney 0:ec559500a63f 57 #define EAI_SERVICE 201
andrewbonney 0:ec559500a63f 58 #define EAI_FAIL 202
andrewbonney 0:ec559500a63f 59 #define EAI_MEMORY 203
andrewbonney 0:ec559500a63f 60
andrewbonney 0:ec559500a63f 61 #define HOST_NOT_FOUND 210
andrewbonney 0:ec559500a63f 62 #define NO_DATA 211
andrewbonney 0:ec559500a63f 63 #define NO_RECOVERY 212
andrewbonney 0:ec559500a63f 64 #define TRY_AGAIN 213
andrewbonney 0:ec559500a63f 65 #endif /* LWIP_DNS_API_DEFINE_ERRORS */
andrewbonney 0:ec559500a63f 66
andrewbonney 0:ec559500a63f 67 #if LWIP_DNS_API_DECLARE_STRUCTS
andrewbonney 0:ec559500a63f 68 struct hostent {
andrewbonney 0:ec559500a63f 69 char *h_name; /* Official name of the host. */
andrewbonney 0:ec559500a63f 70 char **h_aliases; /* A pointer to an array of pointers to alternative host names,
andrewbonney 0:ec559500a63f 71 terminated by a null pointer. */
andrewbonney 0:ec559500a63f 72 int h_addrtype; /* Address type. */
andrewbonney 0:ec559500a63f 73 int h_length; /* The length, in bytes, of the address. */
andrewbonney 0:ec559500a63f 74 char **h_addr_list; /* A pointer to an array of pointers to network addresses (in
andrewbonney 0:ec559500a63f 75 network byte order) for the host, terminated by a null pointer. */
andrewbonney 0:ec559500a63f 76 #define h_addr h_addr_list[0] /* for backward compatibility */
andrewbonney 0:ec559500a63f 77 };
andrewbonney 0:ec559500a63f 78
andrewbonney 0:ec559500a63f 79 struct addrinfo {
andrewbonney 0:ec559500a63f 80 int ai_flags; /* Input flags. */
andrewbonney 0:ec559500a63f 81 int ai_family; /* Address family of socket. */
andrewbonney 0:ec559500a63f 82 int ai_socktype; /* Socket type. */
andrewbonney 0:ec559500a63f 83 int ai_protocol; /* Protocol of socket. */
andrewbonney 0:ec559500a63f 84 socklen_t ai_addrlen; /* Length of socket address. */
andrewbonney 0:ec559500a63f 85 struct sockaddr *ai_addr; /* Socket address of socket. */
andrewbonney 0:ec559500a63f 86 char *ai_canonname; /* Canonical name of service location. */
andrewbonney 0:ec559500a63f 87 struct addrinfo *ai_next; /* Pointer to next in list. */
andrewbonney 0:ec559500a63f 88 };
andrewbonney 0:ec559500a63f 89 #endif /* LWIP_DNS_API_DECLARE_STRUCTS */
andrewbonney 0:ec559500a63f 90
andrewbonney 0:ec559500a63f 91 #if LWIP_DNS_API_DECLARE_H_ERRNO
andrewbonney 0:ec559500a63f 92 /* application accessable error code set by the DNS API functions */
andrewbonney 0:ec559500a63f 93 extern int h_errno;
andrewbonney 0:ec559500a63f 94 #endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/
andrewbonney 0:ec559500a63f 95
andrewbonney 0:ec559500a63f 96 struct hostent *lwip_gethostbyname(const char *name);
andrewbonney 0:ec559500a63f 97 int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
andrewbonney 0:ec559500a63f 98 size_t buflen, struct hostent **result, int *h_errnop);
andrewbonney 0:ec559500a63f 99 void lwip_freeaddrinfo(struct addrinfo *ai);
andrewbonney 0:ec559500a63f 100 int lwip_getaddrinfo(const char *nodename,
andrewbonney 0:ec559500a63f 101 const char *servname,
andrewbonney 0:ec559500a63f 102 const struct addrinfo *hints,
andrewbonney 0:ec559500a63f 103 struct addrinfo **res);
andrewbonney 0:ec559500a63f 104
andrewbonney 0:ec559500a63f 105 #if LWIP_COMPAT_SOCKETS
andrewbonney 0:ec559500a63f 106 #define gethostbyname(name) lwip_gethostbyname(name)
andrewbonney 0:ec559500a63f 107 #define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
andrewbonney 0:ec559500a63f 108 lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
andrewbonney 0:ec559500a63f 109 #define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo)
andrewbonney 0:ec559500a63f 110 #define getaddrinfo(nodname, servname, hints, res) \
andrewbonney 0:ec559500a63f 111 lwip_getaddrinfo(nodname, servname, hints, res)
andrewbonney 0:ec559500a63f 112 #endif /* LWIP_COMPAT_SOCKETS */
andrewbonney 0:ec559500a63f 113
andrewbonney 0:ec559500a63f 114 #endif /* LWIP_DNS && LWIP_SOCKET */
andrewbonney 0:ec559500a63f 115
andrewbonney 0:ec559500a63f 116 #endif /* __LWIP_NETDB_H__ */