Giter Site home page Giter Site logo

as3httpclient's Introduction

Hi there ๐Ÿ‘‹

as3httpclient's People

Contributors

espenhogbakk avatar gabriel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

as3httpclient's Issues

HTTP Header parser

using /r/n to parse HTTP header can be faulty. Would suggest using finite state machine strategy.

Please find the following snippet, hope it helps.

Cheers,
Ping

           /**
     * parse HTTP header
     */ 
    public function parseHeader():void
    {
        _data.position = 0;
        var response:String = _data.readUTFBytes(_data.length);
        _cursor = 0;
        while(_cursor < response.length)
        {
            var ch:String = response.charAt(_cursor);
            switch(_state)
            {
                case RESPONSE_START:
                    if (ch == "H")
                    {
                        _state = RESPONSE_VERSION;
                        _version += ch;
                    }
                    break;
                case RESPONSE_VERSION:
                    if (ch == " ")
                    {
                        _state = RESPONSE_WAIT_STATUS;
                        //_logger.debug("version: " + _version);
                    }
                    else
                    {
                        _version += ch;
                    }
                    break;
                case RESPONSE_WAIT_STATUS:
                    if (ch != " ")
                    {
                        _state = RESPONSE_STATUS_CODE;
                        _statusCode += ch;
                    }
                    break;
                case RESPONSE_STATUS_CODE:
                    if (ch == " ")
                    {
                        _state = RESPONSE_WAIT_STATUS_INFO;
                        //_logger.debug("status code: " + _statusCode);
                    }
                    else
                    {
                        _statusCode += ch;
                    }
                    break;
                case RESPONSE_WAIT_STATUS_INFO:
                    if (ch != " ")
                    {
                        _state = RESPONSE_STATUS_INFO;
                        _statusInfo += ch;
                    }
                    break;
                case RESPONSE_STATUS_INFO:
                    if (ch == "\r")
                    {
                        _state = RESPONSE_CR;
                        //_logger.debug("status info: " + _statusInfo);
                    }
                    else
                    {
                        _statusInfo += ch;
                    }
                    break;
                case RESPONSE_CR:
                    if (ch == "\n")
                    {
                        _state = RESPONSE_LF;
                    }
                    break;
                case RESPONSE_LF:
                    if (ch == "\r")
                    {
                        _state = RESPONSE_HDR_ALMOST_DONE;
                    }
                    else
                    {
                        _state = RESPONSE_KEY;
                        _keyTemp += ch;
                    }
                    break;
                case RESPONSE_KEY:
                    if (ch == ":")
                    {
                        _state = RESPONSE_KEY_SPACE;
                        _key = _keyTemp;
                        _keyTemp = "";
                        //_logger.debug("KEY: " + _key);
                    }
                    else
                    {
                        _keyTemp += ch;
                    }
                    break;
                case RESPONSE_KEY_SPACE:
                    if (ch != " ")
                    {
                        _state = RESPONSE_VALUE;
                        _valueTemp += ch;
                    }
                    break;
                case RESPONSE_VALUE:
                    if (ch != "\r")
                    {
                        _valueTemp += ch;
                    }
                    else
                    {
                        _state = RESPONSE_CR;
                        _value = _valueTemp;
                        _valueTemp = "";
                        _httpHeader.add(_key, _value);
                        //_logger.debug("VALUE: " + _value);
                    }
                    break;
                case RESPONSE_HDR_ALMOST_DONE:
                    if (ch == "\n")
                    {
                        _state = RESPONES_HDR_DONE;
                    }
                    break;
            } // end of switch
            _cursor ++;
            if (_state == RESPONES_HDR_DONE) break;
        } // end of while

        _httpResponse = new HttpResponse(_version, _statusCode, _statusInfo, _httpHeader);
    }

https timeout error

Hi,

I am trying to to send https post request(port 81) to my server from main swf file(loaded from port 99).

Code in my main.swf:
uri = new URI("https://x.x.x.x/myservice.aspx");
uri.scheme = "https"
uri.port = "81";
client.postFormData(uri,variables);

It traces:
Warning: Found secure='true' in policy file from xmlsocket://x.x.x.x:843, but host x.x.x.x does not appear to refer to the local machine. This may be insecure. See http://www.adobe.com/go/strict_policy_files for details.

OK: Policy file accepted: xmlsocket://x.x.x.x:843

OK: Request for resource at xmlsocket://x.x.x.x:81 by requestor from https://x.x.x.x:99/webdev/allfiles/main.swf is permitted due to policy file at xmlsocket://x.x.x.x:843

Request URI: https://x.x.x.x:81/webdev/myservice.aspx (POST)

But I dont get any response from the server & I receive following error after some time:-

[ErrorEvent type="httpTimeoutError" bubbles=false cancelable=false eventPhase=2 text="Timeout"]

Error: Error #2002: Operation attempted on invalid socket.
at flash.net::Socket/flush()
at com.hurlant.crypto.tls::TLSSocket/close()
at com.org.httpclient::HttpSocket/close()
at com.org.httpclient::HttpSocket/onTimeout()
at com.org.httpclient::HttpTimer/onTimer()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

Things I have done :

  1. Returned a policy file at socket 843 on server.
  2. Crossdomain file at root of my server.
  3. Bind server port 81,443 & 99 to https request.
  4. created rule to allow all TCP/UDP connection over all ports.

Am I missing anything.Plz help.

Thanks,
Hishankjain

TLSSocket error (not defined )

Hi Gabriel, I'm getting this error below, do you have a clue why this is happening?
Does it have something to do with the policy server?
Thanks in advance!

ReferenceError: Error #1065: Variable com.hurlant.crypto.tls::TLSSocket is not defined.
at org.httpclient::HttpSocket/onResponseComplete()[/Users/gabe/Projects/as3httpclient/src/org/httpclient/HttpSocket.as:272]
at org.httpclient.io::HttpResponseBuffer/writeBytes()[/Users/gabe/Projects/as3httpclient/src/org/httpclient/io/HttpResponseBuffer.as:121]
at org.httpclient::HttpSocket/onSocketData()[/Users/gabe/Projects/as3httpclient/src/org/httpclient/HttpSocket.as:259]

GOT ALERT! type=0

Hi,
We're getting "GOT ALERT! type=0" when we make a PUT request to Amazon S3 using HTTPS. What might be going on?

Can't re-dispatch events

Currently its impossible to re-dispatch events. For example...

private function statusHandler( event:HttpStatusEvent ):void
{
    dispatchEvent( event );
}

It will throw this error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@16be0a1 to org.httpclient.events.HttpStatusEvent.

To fix, override the clone() method in your event classes. For example:

override public function clone():Event 
{
    return new HttpStatusEvent( response, type, bubbles, cancelable );
}

"Error: No data available" raised in HttpBuffer.as, resolved

Thanks for the library, I've found it to be quite useful! It does have a bug that I encountered during development that I eventually hunted down and resolved.

Every once in a while, the error "No data available" will be thrown from HttpBuffer.readChunks() when readLine() returns null. This will occur when the chunk size (e.g. "3ef\r\n") is split between two TCP packets, something that is infrequent but still allowed. The fix is quite simple, just change the line:
throw new Error("No data available");
To:
return false;
That's currently line 115 of src/org/httpclient/io/HttpBuffer.as.

could I merge in socket OutputProgressEvent support?

Thank you for making this wonderfully cleanly coded library. It lets us all have the full control we need to talk to servers in the way we want.

I have implemented support for OutputProgressEvent events on socket writes. This allowed me to finally upload large photos efficiently.

I would like to submit my modest changes to the main branch. Are you interested? If so, what is the best way of doing that?

Dependency on com.hurland

There is a dependency on com.hurland, might want to mention this in the docs.

https://github.com/gabriel/as3httpclient/blob/master/src/org/httpclient/HttpSocket.as#L8

I downloaded the com.hurland files, but the dependency fails for me:

Error: Error #2030: End of file was encountered.
    at flash.utils::ByteArray/readShort()
    at com.hurlant.crypto.tls::TLSEngine/parseHandshakeHello()[/tmp/test/com/hurlant/crypto/tls/TLSEngine.as:434]
    at com.hurlant.crypto.tls::TLSEngine/parseHandshake()[/tmp/test/com/hurlant/crypto/tls/TLSEngine.as:312]
    at com.hurlant.crypto.tls::TLSEngine/parseOneRecord()[/tmp/test/com/hurlant/crypto/tls/TLSEngine.as:228]
    at com.hurlant.crypto.tls::TLSEngine/parseRecord()[/tmp/test/com/hurlant/crypto/tls/TLSEngine.as:206]
    at com.hurlant.crypto.tls::TLSEngine/dataAvailable()[/tmp/test/com/hurlant/crypto/tls/TLSEngine.as:139]

Any idea what the problem is? In case the script is a wrong version, perhaps you can include the specific version that is working with this script in the repository.

POST fails with ByteArray body with position != 0

When making a POST request, if the request.body is a ByteArray and the array is not at position 0 the request fails.

This looks to be because the Content-Length header is set based on the .length of the body, however during transport it expects there to be .length bytes of data after the current position. It would at least be worth a warning in the documentation for HttpRequest (or possibly changing the code to generate Content-Length using .bytesAvailable instead of .length?)

Http push

Dear gabriel,

I plan to use your lib to communicate with Comet server, is this possible?
Do you have any sample?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.