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

request is not parsed correctly #3

Open
lorypelli opened this issue May 1, 2024 · 28 comments
Open

request is not parsed correctly #3

lorypelli opened this issue May 1, 2024 · 28 comments

Comments

@lorypelli
Copy link

I'm finding issues with your libraries, a lot of time parsing doesn't work and you should return an error which is usually done in go, please do this, it's a good practice to have

@lorypelli
Copy link
Author

error

@474420502
Copy link
Owner

@lorypelli In the earlier versions, error handling and returns were not implemented in order to quickly identify errors. However, based on your feedback, I have added error handling and returns in version v0.9.0 instead of causing panics. The error handling may not be comprehensive enough yet. If you encounter any issues, please feel free to provide feedback. Thank you for your suggestion.

@lorypelli
Copy link
Author

@lorypelli In the earlier versions, error handling and returns were not implemented in order to quickly identify errors. However, based on your feedback, I have added error handling and returns in version v0.9.0 instead of causing panics. The error handling may not be comprehensive enough yet. If you encounter any issues, please feel free to provide feedback. Thank you for your suggestion.

thanks, now it gives an error in -H when pasting this:

curl "https://wails.io/assets/js/6264.be098870.js" ^
  -H "accept: */*" ^
  -H "accept-language: it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7" ^
  -H ^"cookie: ph_phc_UcoO1U6kbh3MRDXFF3Y5ycUIY15UklNky7NNhLyOupC_posthog=^%^7B^%^22distinct_id^%^22^%^3A^%^22018f1bda-30fd-7b0c-b061-76a8445efdb8^%^22^%^2C^%^22^%^24sesid^%^22^%^3A^%^5B1714940203879^%^2C^%^22018f4a66-d367-7919-b99b-bc62268a8bd2^%^22^%^2C1714940203879^%^5D^%^7D^" ^
  -H "referer: https://wails.io/docs/gettingstarted/installation" ^
  -H ^"sec-ch-ua: ^\^"Chromium^\^";v=^\^"124^\^", ^\^"Google Chrome^\^";v=^\^"124^\^", ^\^"Not-A.Brand^\^";v=^\^"99^\^"^" ^
  -H "sec-ch-ua-mobile: ?0" ^
  -H ^"sec-ch-ua-platform: ^\^"Windows^\^"^" ^
  -H "sec-fetch-dest: script" ^
  -H "sec-fetch-mode: no-cors" ^
  -H "sec-fetch-site: same-origin" ^
  -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"

this is from Copy as cURL (cmd) option on chrome, same if I try with bash option

@474420502
Copy link
Owner

474420502 commented May 11, 2024

@lorypelli Supports copying as cURL command only (Bash), I let me check and fix it.

@474420502
Copy link
Owner

@lorypelli The v0.9.1 version has already addressed this issue. If you are still encountering problems, please provide the Bash command with the curl string. I can fix it, but currently, support is limited to curl commands in Bash format only; other formats are not supported at this time.

@lorypelli
Copy link
Author

@lorypelli Supports copying as cURL command only (Bash), I let me check and fix it.

You should give error saying only bash is supported and not windows

@474420502
Copy link
Owner

@lorypelli Supports copying as cURL command only (Bash), I let me check and fix it.

You should give error saying only bash is supported and not windows

The v0.10.0 version has already Add Parse, ParseBash, ParseCmd to make them compatible with the cmd format.

@lorypelli
Copy link
Author

@lorypelli Supports copying as cURL command only (Bash), I let me check and fix it.

You should give error saying only bash is supported and not windows

The v0.10.0 version has already Add Parse, ParseBash, ParseCmd to make them compatible with the cmd format.

Thanks a lot, this is the best support I received in an issue, good...😉🙂

@lorypelli lorypelli changed the title returning pointer err for bad parsing request is not parsed correctly May 11, 2024
@lorypelli
Copy link
Author

I changed the title to better understand what the issue is for other people

@lorypelli
Copy link
Author

still doesn't work

@lorypelli
Copy link
Author

it gives a parse error now

@lorypelli
Copy link
Author

curl 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap' \
  -H 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
  -H 'Referer: https://github.com/474420502/gcurl/issues/3' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"'

image

@lorypelli
Copy link
Author

the alert is from an app I'm making using also your package

@lorypelli
Copy link
Author

tried both with cmd and bash

@474420502
Copy link
Owner

@lorypelli
image
I tried it and it's normal. The above curl bash can be executed smoothly.

@lorypelli
Copy link
Author

@lorypelli
image
I tried it and it's normal. The above curl bash can be executed smoothly.

So, I'm using wrong method, I use Parse function

@lorypelli
Copy link
Author

curl := gcurl.Parse(url)
url is correct

@474420502
Copy link
Owner

@lorypelli you try it v0.10.0

@lorypelli
Copy link
Author

I'm using latest version

@474420502
Copy link
Owner

@lorypelli

scurl := `curl 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap' \
  -H 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
  -H 'Referer: https://github.com/474420502/gcurl/issues/3' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"'`
cu, err := Parse(scurl)
if err != nil {
log.Panic(err)
}
resp, err := cu.Temporary().Execute()
if err != nil {
log.Panic(err)
}

log.Println(resp.ContentString())

image

@lorypelli
Copy link
Author

@lorypelli

scurl := `curl 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap' \
  -H 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
  -H 'Referer: https://github.com/474420502/gcurl/issues/3' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"'`
cu, err := Parse(scurl)
if err != nil {
log.Panic(err)
}
resp, err := cu.Temporary().Execute()
if err != nil {
log.Panic(err)
}

log.Println(resp.ContentString())

image

https://github.com/lorypelli/FetchTTP/blob/main/app.go#L336-L372

@474420502
Copy link
Owner

@lorypelli I think this will help
image

@lorypelli
Copy link
Author

@lorypelli I think this will help image

it adds http protocol twice, either if the url is http or https

@lorypelli
Copy link
Author

image

@lorypelli
Copy link
Author

and URL is not correctly parsed

@lorypelli
Copy link
Author

ah, it's the same error as before

@474420502
Copy link
Owner

@lorypelli The problem may stem from inadequate support for Windows. I'll consider enhancing support for Windows at a later date; I don't have the time this month.

@474420502
Copy link
Owner

@lorypelli Try version v0.11.0, but since I currently don't have access to a Windows system, I'm unable to test your specific scenario. I can only make some attempts based on what's possible.

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