Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPRequest returns a result with OPTIONS but not POST #466

Open
fredrossperry opened this issue Sep 4, 2019 · 6 comments
Open

HTTPRequest returns a result with OPTIONS but not POST #466

fredrossperry opened this issue Sep 4, 2019 · 6 comments
Assignees

Comments

@fredrossperry
Copy link

When I make an HTTP request to my server, which handles CORS, the browser first sends an OPTIONS request, and after that sends my request. A sample program is attached.
But my program receives ResultEvent.RESULT after the OPTIONS, instead of after the POST.
I can see this in the Chrome Dev Tools. I can also see that the POST succeeds and produces expected data.

HTTPTest.zip

@fredrossperry
Copy link
Author

... the result data happens to be XML, if that's interesting.

@greg-dove
Copy link
Contributor

I will take a quick look at this shortly. I am using HttpService also

@fredrossperry
Copy link
Author

I should mention too that this is meant for Javascript, and not SWF.

@greg-dove
Copy link
Contributor

greg-dove commented Sep 5, 2019

[Edited to get XML formatting to appear in the comment]
Hi Fred, I took another look at this. It's actually working in terms of the sequence I think, but not decoding the xml to the requested:

service.resultFormat = HTTPService.RESULT_FORMAT_OBJECT;

you can print the result in the result handler with
resultEvent.message.body

instead of resultEvent.result

I switched it to:
RESULT_FORMAT_E4X

and that makes the attempt to create the result as XML
but gives:

 [RPC Fault faultString="Error #1088: The markup in the document following the root element must be well-formed." faultCode="Client.CouldNotDecode" faultDetail="null"]

because the XML seems to be missing a root tag:

<?xml version="1.0" encoding="utf-8"?><success>false</success><retryable>false</retryable><localStatus>SESSION_NO_SUCH_CUSTOMER</localStatus>

There might still be bugs or things to improve, but I think it's working for the most part.

@greg-dove
Copy link
Contributor

Extra info: I think the relevant parts of this are not yet implemented, which may be the cause:

https://github.com/apache/royale-asjs/blob/develop/frameworks/projects/MXRoyale/src/main/royale/mx/rpc/http/AbstractOperation.as#L1038

I can look into this more when I have time, unless someone else gets there first.

greg-dove added a commit that referenced this issue Oct 16, 2019
@greg-dove
Copy link
Contributor

I added a fix that works for the example provided. Please check the implementation with examples of more complex content if you can and update this issue, preferably with an example of an XML string that does not decode correctly if you see anything that continues to fail. If everything is as it should be, feel free to close the issue.

@greg-dove greg-dove self-assigned this Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants