Re: NPN_PostURLNotify treating my headers as data

Rudi Sherry <[email protected]>
Newsgroups gmane.comp.mozilla.devel.plugins
Message-ID <[email protected]>
More info: Chrome works just fine.

On Sep 18, 2012, at 10:28 AM, Rudi Sherry wrote:

> Hi all,
> 
> I am having trouble adding headers to a POST using NPN_PostURLNotify in Firefox 15.0.1.  As far as I know I'm using NPN_PostURLNotify correctly, but it is putting my header in the data section of the POST.
> 
> I tried two ways: one with a memory buffer and one with a file, with the same results.
> 
> I have tried both '\n' and '\r\n' with the same results.
> 
> Firefox 14.0.1, for memory buffer, shows the same results (I didn't try the file for that).
> 
> Is there something I'm missing?
> 
> ("instance" is my NPP instance).
> 
> // Use Memory Buffer
> NPError err = NPERR_NO_ERROR;
> static const char *sHeaders = "Custom:\tfoobar\nCookie:\tfoobar\n\nPostData\n";
> NPError err = NPN_PostURLNotify( instance,
>        "http://host.com/home.html", NULL,
>        strlen(sHeaders), sHeaders, false, (void *) 1000 );
> 
> 
> // Use file
> static const char *sFilename = "C:\\Temp\\tempdata.txt<smb://Temp//tempdata.txt>";
> static const char *sCustomHeader = "Custom:\tfoobar\n";
> static const char *sCookieHeader = "Cookie:\tfoobar\n";
> static const char *sLF = "\n";
> static const char *sPostData = "PostData\n";
> FILE *f = NULL;
> errno_t ferr = fopen_s( &f, sFilename, "wb" );
> if ( ferr == 0 && f != NULL )
> {
>    fwrite( sCustomHeader, 1, strlen(sCustomHeader), f );
>    fwrite( sCookieHeader, 1, strlen(sCookieHeader), f );
>    fwrite( sLF, 1, strlen(sLF), f );
>    fwrite( sPostData, 1, strlen(sPostData), f );
>    fclose( f );
>    NPError err = NPN_PostURLNotify( instance, "http://host.com/home.html",
>                  NULL, strlen(sFilename), sFilename, true, (void *) 1000 );
> }
> 
> 
> // Fiddler shows this for both:
> 
> POST http://host.com/home.html HTTP/1.1
> Host: host.com<http://host.com>
> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip, deflate
> Connection: keep-alive
> Content-length: 41
> 
> Custom:    foobar
> Cookie:    foobar
> 
> PostData
> 
> _______________________________________________
> dev-tech-plugins mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-plugins
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.