Skip to content

on and sendHeader Method Clarifications #99

@Xylopyrographer

Description

@Xylopyrographer

Excellent resource. Thank-you very much for taking the time to put his together. A significant amount of work.

I'm looking to better understand what is going on with a few of the ESP8266WebServer library methods.

Referring to the WebUpdate example:

Regarding sendHeader(const String& name, const String& value, bool first = false) method.

  1. Does it actually send anything to the client or is it just preparing parts of the header for the next time a send() method is called? (Meaning the method name is more akin to setHeader()?)

  2. sendHeader() seems to operate on a key:value model where name is the key and value is what is set against that key? Meaning name is the literal text to be included in the response header and value is the literal text that follows name? (Assuming as well the method inserts : between the pair?)

  3. Can multiple calls to sendHeader() be made to build up the desired header?

  4. Is the name parameter limited to certain text strings? If so, where are those enumerated?

  5. What is the effect on the header of using the first parameter? Does it change the order of elements assembled by previous sendHeader() calls?

  6. What is used to create the rest of the header after call(s) to sendHeader()? As in, after call(s) to sendHeader(), what is is the final text of the header?

Regarding on(const Uri &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn)

As used in line 34, it has 4 parameters.

  1. For the method parameter, most examples use HTTP_POST or HTTP_GET. What do these expand to and where are they enumerated?

  2. Trying to understand the 4th parameter, ufn. It seems to be the function called to handle file uploads. But under what conditions, or what triggers it to be called instead of the 3rd parameter, fn?

  3. Why prefer that method over using onFileUpload(THandlerFunction fn)?

Thanks for reading this far. Any insight would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions