pp::URLLoader.Open callback returns PP_ERROR_NOACCESS for POST even though the request succeed.

76 views
Skip to first unread message

oh...@beamr.com

unread,
Jul 17, 2016, 10:28:12 AM7/17/16
to Native-Client-Discuss
Hi,

I have the following scenario:
Server A with pnacl
When the client browse to server A the pnacl code is doing http POST to server B using pp::URLLoader.Open().
The call succeed but still the Open callback gets error -7 (PP_ERROR_NOACCESS)
Here is the code snippet:

 pp::URLRequestInfo* _req;
 pp::URLLoader* _urlLoader;
// ...

 _req->SetURL(_url);
 _req->SetMethod("POST");
 _req->SetAllowCrossOriginRequests(true);
_urlLoader->Open(*_req, cc);
// the callback gets -7 later.

Can anyone explain to me why I get the -7 result?
Thanks.




Bill Budge

unread,
Jul 18, 2016, 10:04:28 AM7/18/16
to Native-Client-Discuss
It's impossible to say for sure without seeing the response. But PPB_URLLoader follows the CORS standard for cross origin requests, so I would guess that either your request didn't follow CORS rules, or the server doesn't support CORS responses. Here's a link to the standard:

Nate Tinkler

unread,
Feb 28, 2017, 5:15:09 PM2/28/17
to Native-Client-Discuss
I'm seeing the same behavior as OP.  I'm making a CORS request using pp::URLLoader which completes successfully (both the preflight OPTIONS request as well as the actual POST), however Open() returns PP_ERROR_NOACCESS (-7).

I'm doing this using a pexe loaded into the context of a normal webpage.  I'm not doing extension development (where the same request works just fine, with the same settings and options).

I know the requests have completed successfully because I can watch the entire exchange using the page's dev tools.

One possible issue: I am currently forcing the CORS preflight response using Fiddler.  I've considered that the issue could be setting Access-Control-Max-Age to 1 in the preflight response, and then not including the same Access-Control-Allow-Origin header in the POST response, so I'm going to see if I can modify that response to also include the CORS security headers.  However this is strange behavior.  I can clearly see the request be completed with the dev tools, but I'm still getting PP_ERROR_NOACCESS as the return from Open().

Request data below:

Here is the original OPTIONS request made by the PNaCl component using URLLoader:

    1. Request URL:
    2. Request Method:
      OPTIONS
    3. Status Code:
      200 Fiddler CORSPreflightAllow
    4. Remote Address:
  1. Response Headersview source
    1. Access-Control-Allow-Credentials:
      true
    2. Access-Control-Allow-Headers:
      content-type
    3. Access-Control-Allow-Methods:
      POST
    4. Access-Control-Allow-Origin:
    5. Access-Control-Max-Age:
      1
    6. Content-Length:
      0
  2. Request Headersview source
    1. Accept:
      */*
    2. Accept-Encoding:
      gzip, deflate, sdch, br
    3. Accept-Language:
      en-US,en;q=0.8
    4. Access-Control-Request-Headers:
      content-type
    5. Access-Control-Request-Method:
      POST
    6. Cache-Control:
      no-cache
    7. Connection:
      keep-alive
    8. Host:
    9. Origin:
    10. Pragma:
      no-cache
    11. Referer:
    12. User-Agent:
      Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Here is the Corresponding POST request, also made by the URLLoader

    1. Request URL:
    2. Request Method:
      POST
    3. Status Code:
      200 OK
    4. Remote Address:
  1. Response Headersview source
    1. Connection:
      keep-alive
    2. Content-Length:
      631
    3. Content-Type:
      application/json
    4. Date:
      Tue, 28 Feb 2017 20:47:06 GMT
    5. Server:
      nginx
    6. Strict-Transport-Security:
      max-age=31536000
    7. Strict-Transport-Security:
      max-age=31536000
    8. X-Ionic-Server:
      federation
  2. Request Headersview source
    1. Accept:
      */*
    2. Accept-Encoding:
      gzip, deflate, br
    3. Accept-Language:
      en-US,en;q=0.8
    4. Cache-Control:
      no-cache
    5. Connection:
      keep-alive
    6. Content-Length:
      428
    7. Content-Type:
      application/json; charset=utf-8
    8. Host:
    9. Origin:
    10. Pragma:
      no-cache
    11. Referer:
    12. User-Agent:
      Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Reply all
Reply to author
Forward
0 new messages