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

Support for web sockets #31

Open
sughodke opened this issue Jan 8, 2025 · 0 comments
Open

Support for web sockets #31

sughodke opened this issue Jan 8, 2025 · 0 comments

Comments

@sughodke
Copy link

sughodke commented Jan 8, 2025

Seems like Websockets are ignored in HAR?

Steps to reproduce

Run create_har.py and navigate to https://echo.websocket.org/.ws

Analysis looks like the following

% poetry run integuru --prompt "send messages on a websocket" --model gpt-4o --generate-code
------------------------Successfully analyzed!!!-------------------------------
└── [master_curl] [node_id: 83ea3e62-803c-48ca-aee4-2c2879c39bec]
        [dynamic_parts: []]
        [extracted_parts: ['None']]
        [curl -X GET -H ':authority: echo.websocket.org' -H ':method: GET' -H ':path: /.ws' -H ':scheme: https' -H 'priority: u=0, i' -H 'upgrade-insecure-requests: 1' 'https://echo.websocket.org/.ws']
--------------Generating code------------
└── [master_curl] [node_id: 83ea3e62-803c-48ca-aee4-2c2879c39bec] [dynamic_parts: []] [extracted_parts: ['None']] [input_variables: None] [curl -X GET -H ':authority: echo.websocket.org' -H ':method: GET' -H ':path: /.ws' -H ':scheme: https' -H 'priority: u=0, i' -H 'upgrade-insecure-requests: 1' 'https://echo.websocket.org/.ws']
Aggregated function calls have been saved to 'generated_code.py'
--------------Generated integration code in generated_code.py!!------------

Incorrectly generated code

import requests

def get_echo_websocket_response(cookie_string):
    url = 'https://echo.websocket.org/.ws'
    headers = {
        'priority': 'u=0, i',
        'upgrade-insecure-requests': '1',
        'Cookie': cookie_string
    }
    response = requests.get(url, headers=headers)
    # Since there are no variables to parse, return an empty dictionary
    return {}

cookie_string = 'key1=value1;key2=value2'

# Convert cookie_string to a dict to retrieve values
cookies_dict = dict(item.split('=') for item in cookie_string.split(';'))

# Retrieve values from cookies_dict if needed
value1 = cookies_dict.get('key1')
value2 = cookies_dict.get('key2')

# Call the function
result = get_echo_websocket_response(cookie_string)

print(result)
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

1 participant