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

Multipart support #8

Closed
kawakami-o3 opened this issue Oct 6, 2017 · 8 comments
Closed

Multipart support #8

kawakami-o3 opened this issue Oct 6, 2017 · 8 comments

Comments

@kawakami-o3
Copy link
Contributor

Do you have any plan to support a multipart POST request?
I will code this feature later.

@asciimoo
Copy link
Member

asciimoo commented Oct 6, 2017

@kawakami-o3 this is definitely a missing and useful feature. I'd appreciate if you could implement it.

@vosmith
Copy link
Collaborator

vosmith commented Oct 13, 2017

So I started working on this and gave it a good try. The main issue that there is no way to set custom headers.

Right now all POST requests are forced into the content-type application/x-www-form-urlencoded.

I tried creating new functions like

func (c *Collector) PostMultipart ...

But once it hits scrape, the content gets set. I also tried adding an onRequest callback method to set the header, but then this callback affects all successive requests once it becomes a part of the callback stack.

Frankly I found it difficult to accomplish this without significant changes to how the headers are handled.

@asciimoo
Copy link
Member

So I started working on this and gave it a good try.

Awesome! =)

Right now all POST requests are forced into the content-type application/x-www-form-urlencoded

What about adding a new "Content-Type" string parameter to scrape() function and in case it is not empty we set the content type to that?

@vosmith
Copy link
Collaborator

vosmith commented Oct 14, 2017

Sounds like it should work! I'll go ahead and give it a try👍🏾

@kawakami-o3
Copy link
Contributor Author

I am late...
I planed to add a request data handler instead of requestData map[string]string.
If the handler contains a file, it can decide correct Content-Type.

Should I stop my work?

@asciimoo
Copy link
Member

@kawakami-o3 seems like @vosmith nearly finished the implementation. Let's wait for his solution to avoid duplicated work. What do you think?

@kawakami-o3
Copy link
Contributor Author

I follow you.

vosmith added a commit to vosmith/colly that referenced this issue Oct 16, 2017
asciimoo added a commit that referenced this issue Oct 18, 2017
initial work on multipart requests, issue #8
@asciimoo
Copy link
Member

added in 30e15f6 thank you for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants