arduino DUE and uHTTP librairy doesn't work

Hi..

Just working on a sketch using an arduino DUE, ethernet shield and I'd like to incorporated the uHTTP librairy.

But when I tryed the example include with the lib, It doesn't compile when the arduino DUE is selected but it does when it is UNO.

this is the error send by the compiler:

Build options changed, rebuilding all
C:\Users\o_for\Documents\Arduino\libraries\uHTTP-master\uHTTP.cpp: In member function 'EthernetClient uHTTP::available()':
C:\Users\o_for\Documents\Arduino\libraries\uHTTP-master\uHTTP.cpp:84:52: error: 'strncmp_P' was not declared in this scope
                  if(strncmp_P(buffer, PSTR("OP"), 2) == 0) __method = uHTTP_METHOD_OPTIONS;
                                                    ^
C:\Users\o_for\Documents\Arduino\libraries\uHTTP-master\uHTTP.cpp:149:56: error: 'strncmp_P' was not declared in this scope
                    if(strncmp_P(buffer, PSTR("Auth"), 4) == 0) header = AUTHORIZATION;
                                                        ^
C:\Users\o_for\Documents\Arduino\libraries\uHTTP-master\uHTTP.cpp: In member function 'const char* uHTTP::parse(const char*, char*, const __FlashStringHelper*)':
C:\Users\o_for\Documents\Arduino\libraries\uHTTP-master\uHTTP.cpp:350:56: error: 'strtok_rP' was not declared in this scope
   sub = strtok_rP(act, (const PROGMEM char *) sep, &ptr);
                                                        ^
C:\Users\o_for\Documents\Arduino\libraries\uHTTP-master\uHTTP.cpp: In member function 'const char* uHTTP::parse(const __FlashStringHelper*, char*, const __FlashStringHelper*)':
C:\Users\o_for\Documents\Arduino\libraries\uHTTP-master\uHTTP.cpp:368:105: error: 'strncmp_P' was not declared in this scope
  for(act = buffer; strncmp_P(sub, (const PROGMEM char *) needle, strlen_P((const PROGMEM char *) needle)); act = NULL){
                                                                                                         ^
C:\Users\o_for\Documents\Arduino\libraries\uHTTP-master\uHTTP.cpp:369:56: error: 'strtok_rP' was not declared in this scope
   sub = strtok_rP(act, (const PROGMEM char *) sep, &ptr);

greetings

Nitrof

The DUE has a lot more memory than the UNO. You don't need to use PROGMEM on the DUE. So, don't.

@PaulS

The DUE has a lot more memory than the UNO. You don't need to use PROGMEM on the DUE. So, don't.

I never use that function, it include inside the library. I found couple of place that it used, always something like this:

bool uHTTP::uri(const __FlashStringHelper *uri){
	return (strcmp_P(this->uri(), (const PROGMEM char *) uri) == 0) ? true : false;

}

There is many thing I do not understand in that function so... how could i remove the progmem? should I just erase it and left 'const char *' ?

thank

how could i remove the progmem?

bool uHTTP::uri(const char*uri)
{
	return (strcmp(this->uri(), (const char *) uri) == 0) ? true : false;
}

Ya! I don't believe it !! I've been able to modify the library. I only tried so far to use doc_root example and get the index.htm, so I don't know if other feature still work. I chunk it a lot

So I post code here if anyone find something wrong or want to test it.

header

#ifndef uHTTP_H
#define uHTTP_H

#if (ARDUINO >= 100)
    #include "Arduino.h"
#else
    #include "WProgram.h"
#endif

#include "EthernetClient.h"
#include "EthernetServer.h"

// #define uHTTP_DEBUG

// Sizes
#define uHTTP_BUFFER_SIZE    255
#define uHTTP_METHOD_SIZE    8
#define uHTTP_URI_SIZE       64
#define uHTTP_QUERY_SIZE     64
#define uHTTP_AUTH_SIZE      32
#define uHTTP_TYPE_SIZE      34
#define uHTTP_ORIG_SIZE      16
// #define uHTTP_HOST_SIZE      32
#define uHTTP_BODY_SIZE      255

#define uHTTP_METHOD_OPTIONS 0
#define uHTTP_METHOD_GET     1
#define uHTTP_METHOD_HEAD    2
#define uHTTP_METHOD_POST    3
#define uHTTP_METHOD_PUT     4
#define uHTTP_METHOD_PATCH   5
#define uHTTP_METHOD_DELETE  6
#define uHTTP_METHOD_TRACE   7
#define uHTTP_METHOD_CONNECT 8


typedef struct header_t{
    char type[uHTTP_TYPE_SIZE];
    char auth[uHTTP_AUTH_SIZE];
    char orig[uHTTP_ORIG_SIZE];
    //char host[uHTTP_HOST_SIZE];
    uint16_t length;
};

class uHTTP : public EthernetServer {
    private:


        header_t __head;

        uint8_t __method;

        char *__uri;
        char *__query;
        char *__body;
        const char *parse(const char *needle, char *haystack, const char*sep);
       
    public:
        uHTTP();
        uHTTP(uint16_t port);
        ~uHTTP();

        EthernetClient available();

        header_t head();

        uint8_t method();
        bool method(uint8_t type);

        const char *uri();
        const char *uri(uint8_t segment);
        bool uri(const char *uri);
        bool uri(uint8_t index, const char *uri);
        
        const char *query();
        const char *query(const char *key);

        const char *body();
        const char *data(const char *key);
};

#endif

send the c++ file and example in attachment

uHTTP_SD_DOCROOT.ino (5.07 KB)

uHTTP.cpp (7.43 KB)